Ugh...been doing too much Swift (j/k). The right answer to this question is:
@(kSomeCStringConstant) This works whether it's a #define or a static const char* const. > On Dec 4, 2017, at 15:00 , Greg Parker <[email protected]> wrote: > > >> On Dec 4, 2017, at 2:56 PM, Rick Mann <[email protected]> wrote: >> >>> On Dec 4, 2017, at 14:55 , Greg Parker <[email protected]> wrote: >>> >>>> On Dec 4, 2017, at 2:51 PM, Ben Kennedy <[email protected]> wrote: >>>> >>>>> On Dec 4, 2017, at 2:47 PM, Rick Mann <[email protected]> wrote: >>>>> >>>>> #define NSSTR(s) (@ ## s) <-- magic; this >>>>> doesn't work >>>>> #define kSomeCStringConstant "foo" >>>>> ... >>>>> NSSTR(kSomeCStringConstant) >>>> >>>> You're close. The preprocessor is removing the quotation marks, breaking >>>> the syntax. You don't need to token paste; simply remove the '##' from the >>>> NSSTR() def. >>>> >>>> #define NSSTR(s) (@ s) >>> >>> You can also skip the middleman and use `@kSomeCStringConstant`. After the >>> preprocessor runs it will be `@"foo"` which the ObjC compiler is perfectly >>> happy with. >> >> Tried that, too. Same error: >> >> MCP.m:262:54: Unexpected '@' in program > > What compiler version are you using? > Is this file compiled as Objective-C? > Is the #define spelled differently than you wrote? > Does anything look wrong with that line in the output of Product > Perform > Action > Preprocess ? > > > -- > Greg Parker [email protected] Runtime Wrangler > > -- Rick Mann [email protected] _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
