digitalmars.D.bugs - [Issue 12546] New: DMD does not generate required symbols for linker
- d-bugmail puremagic.com (60/60) Apr 08 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12546
https://d.puremagic.com/issues/show_bug.cgi?id=12546 Summary: DMD does not generate required symbols for linker Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: major Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: tomerfiliba gmail.com PDT --- When using templates defined in another module (via an alias), all the files must be compiled together or link errors ensue. For example: Compile together $ dmd main.d mymodule.d && echo "ok" ok Compile separately $ dmd -c main.d && dmd -c mymodule.d && dmd main.o mymodule.o main.o:(.data._D78TypeInfo_S8mymodule40__T15TypedIdentifierVAyaa6_4d7954797065Z15TypedIdentifier6__initZ+0x40): undefined reference to `_D8mymodule40__T15TypedIdentifierVAyaa6_4d7954797065Z15TypedIdentifier8__xopCmpFKxS8mymodule40__T15TypedIdentifierVAyaa6_4d7954797065Z15TypedIdentifierKxS8mymodule40__T15TypedIdentifierVAyaa6_4d7954797065Z15TypedIdentifierZi' main.o:(.data._D78TypeInfo_S8mymodule40__T15TypedIdentifierVAyaa6_4d7954797065Z15TypedIdentifier6__initZ+0x48): undefined reference to `_D8mymodule40__T15TypedIdentifierVAyaa6_4d7954797065Z15TypedIdentifier8toStringMxFZAya' collect2: error: ld returned 1 exit status --- errorlevel 1 This screws up our build system (which builds each file separately) Here is the code for reproducing this error: ============================================= main.d ============================================= import mymodule; void main() { int dict[MyType]; auto x = dict[MyType(0)]; } ============================================= mymodule.d ============================================= module mymodule; import std.string; struct TypedIdentifier(string NAME) { int value; this(int val) { value = val; } int opCmp(ref const int rhs) const { return value > rhs ? 1 : (value < rhs ? -1 : 0); } string toString() const { return format("%s(%s)", NAME, value); } } alias MyType = TypedIdentifier!"MyType"; -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 08 2014