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

meta meta at gmail.com
Sat Mar 5 12:32:46 UTC 2022


On Saturday, 5 March 2022 at 11:52:04 UTC, Adam D Ruppe wrote:
> 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
>
> There's no benefit to using extern(C). Why would you want it?
>
>> is also necessary when someone wants to allow their library to 
>> generate binding for other languages.
>
> This is the *only* reason to use it and this is the same with 
> and without betterC.


There is if you want your code to be used within a C project, or 
any other languages that has C FFI (C#, Rust, Swift, GO to some 
extent)

Better C is very valuable, Rust has to go throught a lot just to 
provide similar functionality we get here

https://dev.to/dandyvica/how-to-call-rust-functions-from-c-on-linux-h37


I agree with OP, extern C should be the default in betterC mode!


More information about the Digitalmars-d mailing list