extern(C) symbol conflicts

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 27 02:57:47 PST 2015


On 1/26/2015 11:06 AM, Steven Schveighoffer wrote:
> Is there a good reason why we shouldn't allow the duplicate declaration in
> multiple modules? I understand for D symbols -- those are actually different
> symbols.

D's interface to C and C++ does not adopt C and C++ semantics, in particular, it 
does not adopt C and C++ name lookup rules, function overloading rules, template 
instantiation rules, etc. This is on purpose to reduce the complexity of the 
language.

As in C and C++, it is up to the D programmer to follow the One Definition Rule 
when interfacing with those languages. Declaring the same function in multiple 
modules is a bad idea.

(Yes, I know, we had to bend that a bit to make C++ namespaces work, but we did 
as little as possible.)


More information about the Digitalmars-d mailing list