How to convert these constructs to D?

Craig Dillabaugh craig.dillabaugh at gmail.com
Sun Dec 1 17:12:05 PST 2013


On Sunday, 1 December 2013 at 18:51:51 UTC, Gary Willoughby wrote:
> On Sunday, 1 December 2013 at 03:20:49 UTC, Craig Dillabaugh 
> wrote:
>> On Saturday, 30 November 2013 at 14:53:35 UTC, Gary Willoughby 
>> wrote:
>>> I'm porting some C headers and wondered how would i convert 
>>> the following to D:
>>>
>>> #define pthread_self() GetCurrentThreadId()
>>>
>>> #define pthread_handler_t void * __cdecl
>>>
>>> typedef void * (__cdecl *pthread_handler)(void *);
>>>
>>> #define set_timespec_nsec(ABSTIME,NSEC) { \
>>> GetSystemTimeAsFileTime(&((ABSTIME).tv.ft)); \
>>> (ABSTIME).tv.i64+= (__int64)(NSEC)/100; \
>>> (ABSTIME).max_timeout_msec= (long)((NSEC)/1000000); \
>>> }
>>
>> Maybe you have already solved all your problems, but have you 
>> tried DStep with this header?  I used it on FFTW3, which is 
>> basically one GIANT C 100 line macro, and it 'seems' to have 
>> done a great job on that. However, in other cases it just 
>> seems to have dropped some defines altogether, so your mileage 
>> may vary.
>>
>> Craig
>
> To be honest i didn't. The last time i tried DStep i had 
> problems with compilation. I'll take another look though. I'm 
> basically porting all the mysql-client headers which i thought 
> would be pretty straight forward but it's taking a little more 
> thought than i anticipated.

I think you end up with a bit nicer interface if you hand role 
your own, but at least DStep can take care of a good bit of the 
grunt work for you.  I had some trouble getting it running the 
first time (mostly my own fault), but am now glad I made the 
effort.


More information about the Digitalmars-d-learn mailing list