extern(C) symbol conflicts
Jonathan Marler via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jan 29 14:07:04 PST 2015
On Tuesday, 27 January 2015 at 18:13:36 UTC, Steven Schveighoffer
wrote:e or the other, even though they are the same.
>
> I understand the idea behind keeping the lookup rules
> consistent. But C lookup rules ARE simple.
>
> I would say if two extern(C) declarations are identical (i.e.
> same parameter types, same attributes), they don't conflict.
> What does this break?
>
> -Steve
This extern(C) thing is a bit odd. With C, you can include as
many headers and declare the same function as many times as you
want to. D is breaking this functionality. However, some may
see this as a feature. Suppose you wanted to optimize where you
were declaring your function prototypes by making sure there were
no duplications? In C, I can't think of a way to do this. In D
however, it looks like this would cause an error.
I kinda agree that maybe D should handle it the same way C does,
but another thought comes to mind. Say two libraries declared
the same extern(C) function but they used different types or
different type qualifiers. You would have to go to one of the
libraries and have them modify their's to be identical to the
other right? Well, the difference now is that instead of them
normalizing their declarations you can suggest that everyone use
the same modules for declaring extern(C) functions. This may
have been impossible to do in an old language but since D is
relatively new, this doesn't seem to unreasonable to do. Anyway,
just some thoughts...I think this problem may be more complex
then it seems.
More information about the Digitalmars-d
mailing list