Created
January 10, 2013 06:23
-
-
Save tjw/4499886 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <stdio.h> | |
#define UNIQUE_CONST_PTR2(X) ({ static unsigned X; &X; }) | |
#define CAT(x,y) x##y | |
#define UNIQUE_CONST_PTR1(X, Y) UNIQUE_CONST_PTR2(CAT(X,Y)) | |
#define UNIQUE_CONST_PTR(KEY) UNIQUE_CONST_PTR1(KEY, __COUNTER__) | |
int main(int argc, char *argv[]) | |
{ | |
const void *u1 = UNIQUE_CONST_PTR(A); | |
const void *u2 = UNIQUE_CONST_PTR(A); | |
printf("u1 = %p\n", u1); | |
printf("u2 = %p\n", u2); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment