Should C linkage (aka "extern (C)") be the default when using "betterC"?

max haughton maxhaton at gmail.com
Sat Mar 5 17:09:22 UTC 2022


On Saturday, 5 March 2022 at 11:23:05 UTC, rempas wrote:
> Am I the only one that things this way? If I'm not wrong, other 
> than some (mostly runtime) advantages that "betterC" offers, It 
> is also necessary when someone wants to allow their library to 
> generate binding for other languages.
>
> So I would say that not having to type "extern(C):" in the top 
> of every file, would be great. Another things we could have is 
> a compiler switch to choose the default linkage we want. Unless 
> this is possible and I just not know it...

Basically pointless. The linkage of internal symbols has almost 
no relevance to a projects usability from C. You'd also be 
throwing away anything that requires name mangling, for zero real 
benefit.

If you want to expose a symbol to C then use extern(C). This is 
not hard to do.


More information about the Digitalmars-d mailing list