Skip to content

Instantly share code, notes, and snippets.

@fjolnir
Created May 30, 2012 01:17
Show Gist options
  • Save fjolnir/2832103 to your computer and use it in GitHub Desktop.
Save fjolnir/2832103 to your computer and use it in GitHub Desktop.
The weirdest macro expansion
#define TQAssertSoft(cond, domain, code, fmt, ...) \
do { \
if(!(cond)) { \
if(aoError) \
*aoError = [NSError errorWithDomain:(domain) code:(code) userInfo:nil]; \
TQLog(fmt, ##__VA_ARGS__); \
return NO; \
} \
} while(0)
TQAssertSoft(aArgument.identifier == nil,
kTQSyntaxErrorDomain, kTQUnexpectedIdentifier,
@"First argument of a block can not have an identifier");
/*
Results in:
TQSyntaxTree.m:91:3: warning: class method '+errorWithDomain:kTQUnexpectedIdentifier:userInfo:' not found (return type defaults to 'id')
TQAssertSoft(aArgument.identifier == nil,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./TQSyntaxTree.h:28:16: note: expanded from:
*aoError = [NSError errorWithDomain:(domain) code:(code) userInfo:nil]; \
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment