Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mikeash
Created September 19, 2017 15:08
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 mikeash/8fa29b20b94e74c5fba6bf70126707b6 to your computer and use it in GitHub Desktop.
Save mikeash/8fa29b20b94e74c5fba6bf70126707b6 to your computer and use it in GitHub Desktop.
/*usr/bin/true
clang -framework Cocoa -g compile-time-class.m && ./a.out
exit;*/
#import <Foundation/Foundation.h>
#define COMPILE_TIME_CLASS(name) ^{ \
extern void *OBJC_CLASS_$_ ## name; \
return (Class)&OBJC_CLASS_$_ ## name; \
}()
int main(int argc, char **argv) {
NSLog(@"%@", COMPILE_TIME_CLASS(NSString));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment