Skip to content

Instantly share code, notes, and snippets.

@Seikilos
Last active August 29, 2015 14:17
Show Gist options
  • Save Seikilos/48965f4d654672566c73 to your computer and use it in GitHub Desktop.
Save Seikilos/48965f4d654672566c73 to your computer and use it in GitHub Desktop.
Macro Debugging macro to display macros, displays if macro is undefined. This is not meant to be executed in anyway, just visual comparison
#define COMBINE1(X,Y) X##_##Y
#define COMBINE(X,Y) COMBINE1(X,Y)
#define QUOTE_EX(p, dummy) #p
#define QUOTE(p) QUOTE_EX(p, dummy)
#define DefMacro(p) \
class COMBINE(Dummy_##p, __COUNTER__){\
void info(){\
auto undefinedWhenTrue = #p == QUOTE(p); \
auto value = QUOTE(p);\
auto line = ## __LINE__;\
auto file = ##__FILE__ ;\
}\
};
#define Goo 32666
#define Goo2
DefMacro(Goo)
DefMacro(Goo2)
DefMacro(undefined)
Output:
class Dummy_Goo_0{ void info(){ auto undefinedWhenTrue = "Goo" == "32666"; auto value = "32666"; auto line =20; auto file ="Source.cpp" ; } };
class Dummy_Goo2_1{ void info(){ auto undefinedWhenTrue = "Goo2" == ""; auto value = ""; auto line =21; auto file ="Source.cpp" ; } };
class Dummy_undefined_2{ void info(){ auto undefinedWhenTrue = "undefined" == "undefined"; auto value = "undefined"; auto line =22; auto file ="Source.cpp" ; } };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment