Skip to content

Instantly share code, notes, and snippets.

@JadenGeller
Last active February 26, 2018 10:39
Show Gist options
  • Save JadenGeller/532a2c393f06795a1c6d to your computer and use it in GitHub Desktop.
Save JadenGeller/532a2c393f06795a1c6d to your computer and use it in GitHub Desktop.
C Macro Tuple
#include <stdio.h>
#define LEFT_(X, Y) X
#define LEFT(T) LEFT_ T
#define RIGHT_(X, Y) Y
#define RIGHT(T) RIGHT_ T
#define SUM(TUPLE) LEFT(TUPLE) + RIGHT(TUPLE)
int main(int argc, char *argv[]) {
printf("%i\n", SUM((3, 4))); // -> 7
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment