[D-runtime] [D-Programming-Language/druntime] eddc04: Merge branch 'master' of git://github.com/ibuclaw/...

Jonathan M Davis jmdavisProg at gmx.com
Sun Feb 6 20:57:18 PST 2011


On Sunday 06 February 2011 20:35:23 Brad Roberts wrote:
> Switching just monitor back to the c version gets win32 back in working
> shape.  So, exploring from there what's wrong, I went to a hybrid version,
> the .c file referencing the global variables (_monitor_critsec and inited)
> extern(C)'ed from the .d version.  Still works.  From there, I moved to
> using the .d version of _STI_monitor_staticctor.  That works for the
> druntime unit tests, but not for phobos' tests.
> 
> You can see the source of what I used here:
>   https://github.com/braddr/druntime/commits/win32-monitor-broken
> 
> The point where it works, with a mostly .c file:
>  
> https://github.com/braddr/druntime/commit/6c2f4d1b960c8f227a1ee033f072504a
> 12d94e36
> 
> The point where I've moved the ctor to the .d file:
>  
> https://github.com/braddr/druntime/commit/7d43689996a63ee0195a55c8d3836edf
> 5e59e6e6
> 
> So.. what am I missing?  Is there something special about win32 functions
> that start with an underscore?  Is there something special about win32
> when it comes to linking one lib into another?  That it works for
> druntime's unittest and not phobos's is confusing to me.  I do next to no
> win32 programming (completely zero except for dmd), so I'm unfamiliar with
> any of it's idiosyncrasies.

I don't know anything about this particular case. However, it is quite common 
for functions which are standard on Posix systems but which are not in standard 
C to be on Windows except that Microsoft prepends an underscore on them. So, if 
you have the function func on a Posix system but which isn't standard C, there's 
a decent chance that it exists on Windows as _func.

It makes it _really_ annoying when writing cross-platform code in C++, since 
often the function is on both Linux and Windows and does exactly the same thing 
on both except that for some reason Microsoft decided to put an underscore on 
the front of it. So, you end up having to write wrapper functions all over the 
place if you don't want your code to have #ifdef WIN32 and the like spread 
throughout.

- Jonathan M Davis


More information about the D-runtime mailing list