Created
September 15, 2012 20:42
-
-
Save MitMaro/3729657 to your computer and use it in GitHub Desktop.
Swap Macro
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
/* If you have this it would not break */ | |
#define SWAP(x, y, T) do { T temp##x##y = x; x = y; y = temp##x##y; } while (0) | |
int main(void) { | |
int temp; | |
int a = 1; | |
int b = 2; | |
SWAP(a, b, int); | |
} | |
/* Would be: */ | |
int main(void) { | |
int temp = 3; | |
int a = 1; | |
int b = 2; | |
do { int temp12 = x; x = y; y = temp12; } while (0); | |
} | |
/* Which is ok */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment