Skip to content

Instantly share code, notes, and snippets.

@benstiglitz
Created August 11, 2011 15:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benstiglitz/1139954 to your computer and use it in GitHub Desktop.
Save benstiglitz/1139954 to your computer and use it in GitHub Desktop.
Hygenic and shadow-safe MIN.
#define MIN_PASTE(A,B) A##B
#define MIN_IMPL(A,B,L) ({ __typeof__(A) MIN_PASTE(__a,L) = (A); __typeof__(B) MIN_PASTE(__b,L) = (B); MIN_PASTE(__a,L) < MIN_PASTE(__b,L) ? MIN_PASTE(__a,L) : MIN_PASTE(__b,L); })
#define MIN(A,B) MIN_IMPL(A,B,__COUNTER__)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment