I have a very simple macro that I use for shorthand when declaring exceptions. When in debug mode it adds the current file and line number.
I’m in the process of modifying my code to support unicode, and suddenly I’m getting “undeclared identifier” errors whenever my macro is used. I’m probably missing something really simple, as the macro itself is rather simple. Can anyone tell what the issue is?
Here’s the macro declaration:
#ifdef _DEBUG
#define EXCEPTION(msg, mm) Exception(msg, mm, _T(__FILE__), _T(__LINE__))
#else
#define EXCEPTION(msg, mm) Exception(msg, mm)
#endif
I don’t think it’s needed, but just in case, here’s the Exception constructor declaration:
Exception(LPCTSTR msg, BOOL manageMsg = FALSE, LPCTSTR f = NULL, int l = -1);
When compiling in release mode I don’t get any errors, but when in debug mode I do, so it’s something with the __FILE__ and __LINE__ bits, but I can’t figure out what the actual issue is.
The
__LINE__macro evaluates to an integer. The_Tmacro puts anLon the front of strings to make them Unicode strings. It’s meant to be followed by an opening double quotation mark, likeL"file.cpp". But in your case, it’s followed by the integer literal that__LINE__expands to. You’re getting something like this:L23. Get rid of the second_Tcall.This might have been more easily diagnosed if you had included the name of the identifier that the compiler didn’t recognize. Compilers usually include that information in their error messages.