[Issue 12754] New: MAC link error for template to static value

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri May 16 03:57:14 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12754

          Issue ID: 12754
           Summary: MAC link error for template to static value
           Product: D
           Version: D2
          Hardware: All
                OS: Mac OS X
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: monarchdodra at gmail.com

Currently blocking
https://github.com/D-Programming-Language/phobos/pull/2172/files#r12711667

Reproducible only on MAC. Requires 2 "library" files, and a "client" file.

We'll call the library "foo":

//-----
//foo/traits.d
module foo.traits;

template lvalueInit(T)
{
    static lvalueInit = immutable(T).init;
}
//-----

//-----
//foo/file.d
module foo.file;

import foo.traits;

struct Impl
{

}

struct F
{
    Impl i;
    this(int)
    {
        i = lvalueInit!Impl;
    }
}
//-----

That's it for the "library".
We compile it as such:

dmd -lib foo/traits.d foo/file.d -ofmylib

>From there, create a simple main.d:
//-----
//main.d
module main;

import foo.file;

void main()
{
    auto f = F(5);
}
//-----

Then build...
dmd mylib.a -run main.d
Undefined symbols for architecture x86_64:
 
"_D3foo6traits32__T10lvalueInitTS3foo4file4ImplZ10lvalueInityS3foo4file4Impl",
referenced from:
      _D3foo4file1F6__ctorMFNciZS3foo4file1F in mylib.a(file_3_46.o)
ld: symbol(s) not found for architecture x86_64

--


More information about the Digitalmars-d-bugs mailing list