www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19694] New: Cannot put Objective-C classes in structs

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

          Issue ID: 19694
           Summary: Cannot put Objective-C classes in structs
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: doob me.com

The following code fails to link with DMD 2.085.0-beta.1

extern (Objective-C) class NSObject {}

struct Foo
{
    NSObject o;
}

void main() {}

The error is:

Undefined symbols for architecture x86_64:
  "__D4main8NSObject7__ClassZ", referenced from:
      __D25TypeInfo_xC4main8NSObject6__initZ in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: linker exited with status 1

This issue occurs due to no classinfo is outputted for Objective-C classes.
This is intentional, but I'm not sure how to fix it. Global, local or TLS
variables or instance variables for classes don't require the classinfo, not
sure why a struct field requires it.

--
Feb 23 2019