[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 23:56:40 PST 2011


On Sunday 06 February 2011 23:27:07 Walter Bright wrote:
> Jonathan M Davis wrote:
> > 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.
> 
> The "some reason" is so that you can write assembler code that can call
> any C function. Without the leading _, any C function that has the same
> spelling as a macro assembler pseudo-op or register will fail to assemble.
> 
> Linux avoided that problem by having a really ugly asm syntax that won't
> conflict with C names. Linux assembler format really sucks all the joy
> out of writing in assembler.

I'm afraid that you lost me on that one. Practically every C function in 
existence starts with a normal letter rather than an underscore. Why would 
functions from Microsoft or Posix be any different? What about them causes 
problems where user-defined functions wouldn't?

I can see why having a C function with the same name as a macro assembler 
pseudo-op or register might cause a problem, but why wouldn't _all_ C functions 
have that problem then? The only place that I'm aware of where underscores are 
typical prepended on C function names is on functions which Microsoft provides 
which are not standard C functions but almost certainly - if not definitely - can 
be found on Posix systems (typically as part of the Posix standard). I don't see 
why those functions would cause problems without underscores but other functions 
wouldn't.

- Jonathan M Davis


More information about the D-runtime mailing list