Skip to content

Instantly share code, notes, and snippets.

@thebecwar
Last active June 15, 2016 14:40
Show Gist options
  • Save thebecwar/80565414902b73349dd86ce7614d85ce to your computer and use it in GitHub Desktop.
Save thebecwar/80565414902b73349dd86ce7614d85ce to your computer and use it in GitHub Desktop.
BADMACRO
#define BADMACRO(t, s, f) \
{\
##t str[] = s; \
f << str << endl; \
}
#define BADMACRO2(t, s, f) \
{ \
BADMACRO(##t, ##s, ##f) \
}
int main()
{
BADMACRO(WCHAR, L"String1", wcout);
BADMACRO(CHAR, "String2", cout);
BADMACRO2(WCHAR, L"String3", wcout);
BADMACRO2(CHAR, "String4", cout);
}
// After preprocessing:
int main()
{
{WCHAR str[] = L"String1"; wcout << str << endl; };
{CHAR str[] = "String2"; cout << str << endl; };
{ {WCHAR str[] = L"String3"; wcout << str << endl; } };
{ {CHAR str[] = "String4"; cout << str << endl; } };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment