MSVC 2013 optimizes our expression. Next entry
#define ERROR 1
void somefunction(int level, char const* msg) {
printf("FUNC1 %d: %s\n", level, msg);
}
void someotherfunction(int level, char const* msg) {
printf("FUNC2 %d: %s\n", level, msg);
if (level >= ERROR) {
exit(1);
}
}
#define logevent(level, msg) \
do { \
int _level = level; \
somefunction(_level, msg); \
someotherfunction(_level, msg); \
if (_level >= ERROR) \
__assume(0); \
} while (0)
int _tmain(int argc, _TCHAR* argv[])
{
logevent(ERROR, "HALLO");
printf("Hallo\n");
getchar();
return 0;
}
will compile in
00CB1000 push 0CB2120h
00CB1005 push 1
00CB1007 push 0CB2100h
00CB100C call dword ptr ds:[0CB2090h]
00CB1012 push 0CB2120h
00CB1017 push 1
00CB1019 push 0CB2110h
00CB101E call dword ptr ds:[0CB2090h]
00CB1024 add esp,18h
00CB1027 push 1
00CB1029 call dword ptr ds:[0CB208Ch]
source
share