Skip to content

Instantly share code, notes, and snippets.

@holyhan
Last active August 20, 2018 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save holyhan/89154baf4ff60be8acab5d39f64e1fec to your computer and use it in GitHub Desktop.
Save holyhan/89154baf4ff60be8acab5d39f64e1fec to your computer and use it in GitHub Desktop.
Use _Pragma to replace #pragma, so that to resolve two pragmas in a single macro。
#define LEAK_PRAGMA_BEGIN \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic warning \"-Warc-performSelector-leaks\"")
#define LEAK_PRAGMA_END \
_Pragma("clang diagnostic pop")
@interface AClass : NSObject
- (void)doSomething;
@end
@implementation AClass
- (void)doSomething
{
NSLog(@"Do something!");
}
@end
int main(int argc, char const *argv[])
{
LEAK_PRAGMA_BEGIN
[[AClass new] performSelector:@selector(doSomething)];
LEAK_PRAGMA_BEGIN
return 0;
}
@hdw09
Copy link

hdw09 commented Aug 20, 2018

贼啦六

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment