Last active
June 15, 2016 14:40
-
-
Save thebecwar/80565414902b73349dd86ce7614d85ce to your computer and use it in GitHub Desktop.
BADMACRO
This file contains 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
#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