Bug 19694 – Cannot put Objective-C classes in structs

Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Mac OS X
Creation time
2019-02-23T11:32:13Z
Last change time
2024-12-13T19:02:32Z
Keywords
objc
Assigned to
No Owner
Creator
Jacob Carlborg
Moved to GitHub: dmd#19541 →

Comments

Comment #0 by doob — 2019-02-23T11:32:13Z
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.
Comment #1 by destructionator — 2023-09-26T00:13:39Z
I saw this too recently, I think it is because it is trying to reference them for precise gc info. I hacked around it by wrapping the member in a union {} struct Foo { union { NSObject obj; } } but i agree it shouldn't require this.
Comment #2 by robert.schadek — 2024-12-13T19:02:32Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19541 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB