[Issue 4377] New: Support __gshared for easier D 2 compatibility
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jun 23 16:16:34 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4377
Summary: Support __gshared for easier D 2 compatibility
Product: D
Version: D1
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: torhu at yahoo.com
--- Comment #0 from torhu at yahoo.com 2010-06-23 16:16:31 PDT ---
It be would nice if D 1.x compilers accepted the __gshared keyword. The need
for this comes up a lot when trying to make code that is ported from C work
with both D 1 and D 2. Or even Java, this is an issue for DWT too.
One typical example that won't work in D 2 is this:
---
int x = 1;
int y = 2;
struct S { int* ptr; }
S[2] s = [{ &x }, { &y }];
---
Because the addresses of x and y are not known at link time in D 2, they are
not accepted in static initializers.
x and y would typically be structs or function pointers, and the whole thing
would be a lot more complex than this example. And there would be a whole lot
of this stuff in the file too. Slapping a "__gshared:" on top of the file is
an easy fix, but then it won't compile with D 1.x compilers.
I know there are several ways to make this work, but none of them are that
nice. Using lots of big string mixins or moving all the initializers into
module constructors? Ugh.
Since __gshared starts with two underscores, it shouldn't conflict with user
code either.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list