Created
December 12, 2013 23:51
-
-
Save awreece/7937730 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <stdio.h> | |
// With love from http://stackoverflow.com/a/13459454/447288 | |
#define EVAL0(...) __VA_ARGS__ | |
#define EVAL1(...) EVAL0 (EVAL0 (EVAL0 (__VA_ARGS__))) | |
#define EVAL2(...) EVAL1 (EVAL1 (EVAL1 (__VA_ARGS__))) | |
#define EVAL3(...) EVAL2 (EVAL2 (EVAL2 (__VA_ARGS__))) | |
#define EVAL4(...) EVAL3 (EVAL3 (EVAL3 (__VA_ARGS__))) | |
#define EVAL(...) EVAL4 (EVAL4 (EVAL4 (__VA_ARGS__))) | |
#define MAP_END(...) | |
#define MAP_OUT | |
#define MAP_GET_END() 0, MAP_END | |
#define MAP_NEXT0(item, next, ...) next MAP_OUT | |
#define MAP_NEXT1(item, next) MAP_NEXT0 (item, next, 0) | |
#define MAP_NEXT(item, next) MAP_NEXT1 (MAP_GET_END item, next) | |
#define MAP0(f, x, peek, ...) f(x) MAP_NEXT (peek, MAP1) (f, peek, __VA_ARGS__) | |
#define MAP1(f, x, peek, ...) f(x) MAP_NEXT (peek, MAP0) (f, peek, __VA_ARGS__) | |
#define MAP(f, ...) EVAL (MAP1 (f, __VA_ARGS__, (), 0)) | |
#define STR(x) #x | |
#define ARG(x) " " STR(x) ":%x" | |
#define TRACE(...) printf("%s:%d" MAP(ARG, __VA_ARGS__) "\n", __func__, __LINE__, __VA_ARGS__); | |
int main(int argc, char** argv) { | |
int x = 0; | |
int y = 1; | |
int z = 0; | |
// printf(__func__ ":%d x:%x y:%x z:%x", __LINE__, x, y, z); | |
TRACE(x, y, z); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment