[Issue 17747] extern(C) shared static module constructor should be called in betterC programs
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Sep 14 12:55:39 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=17747
--- Comment #8 from Steven Schveighoffer <schveiguy at yahoo.com> ---
(In reply to anonymous4 from comment #7)
> C abi is requested with extern(C) here, sure they are different.
Essentially, what I'm saying is:
mod1.d:
int x;
extern(C) static this()
{
x = 5;
}
mod2.d:
import mod1;
int y;
extern(C) static this()
{
y = x + 1; // should be 6, but could be 1 if executed in the wrong order
}
Druntime knows how to make this work. C does not. You are changing the semantic
meaning of static this() by putting an extern(C) on it, and I don't think it's
a good idea. People are used to this "just working".
You also likely will break code, as I think there are many files with
extern(C): at the top, for which this would change the semantics.
--
More information about the Digitalmars-d-bugs
mailing list