Last active
August 29, 2015 14:05
-
-
Save zodiac1111/a5f49a84849408757fe1 to your computer and use it in GitHub Desktop.
swap两个数,一种类型无关.宏, 来自 kernel.h
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
#define swap(a, b) \ | |
do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) | |
/// 临时变量名字, | |
/// from http://stackoverflow.com/questions/3982348/implement-generic-swap-macro-in-c | |
#define swap(x, y) \ | |
do { typeof(x) temp##x##y = x; x = y; y = temp##x##y; } while (0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment