if I have the following function
Code:
inline void SHOWERROR(char *str)
{
#ifdef _DEBUG
char buf[1024];
char file[] = __FILE__;
int line = __LINE__;
sprintf(buf, "File: %s\nLine: %d\n%s", file, line, str);
MessageBox(0, buf, "Error", 0);
#endif
}
Assuming _DEBUG was not defined, would the compiler generate any extra instruction in this if statement?
Code:
if (!(memcpy(pDest, pSource, size) ) )
{
SHOWERROR("Error Message");
}
or would it be better to use something like this
Code:
#define SHOWERROR(s) { char buf[1024]; \
char file[] = __FILE__; \
int line = __LINE__; \
sprintf(buf, "File: %s\nLine: %d\n%s",file,line,s); \
MessageBox(0, buf, "Error", 0); }
...
if (!(memcpy(pDest, pSource, size) ) )
{
#ifdef _DEBUG
SHOWERROR("Error Message");
#endif
}