Error: undefined identifier 'selector'

Mike McKee via Digitalmars-d-learn digitalmars-d-learn at
Mon Dec 14 12:46:41 PST 2015

When I run this piece of code:

// FROM:
module main;

extern (Objective-C)
interface Class
   NSString alloc() @selector("alloc");

extern (Objective-C)
interface NSString
   NSString initWithUTF8String(in char* str) 
   void release() @selector("release");

extern (C) void NSLog(NSString, ...);
extern (C) Class objc_lookUpClass(in char* name);

void main()
   auto cls = objc_lookUpClass("NSString");
   auto str = cls.alloc().initWithUTF8String("Hello World!");

I get this error:

$ dmd -L-framework -LFoundation test.d
test.d(7): Error: undefined identifier 'selector'
test.d(13): Error: undefined identifier 'selector'
test.d(14): Error: undefined identifier 'selector'

It just doesn't like that @selector statement. What's the catch?

More information about the Digitalmars-d-learn mailing list