How does the TEXT("x") macro expand to L"x" if unicode is defined and "x" if unicode is not defined because when I try to compile the following code it says "error #1049: Syntax error in macro parameters."
#define T("x") "x"
int main()
{
}
Lookup the tchar.h
header in your installation. You'd get something like the following:
#define __T(x) L ## x
In Unicode mode, the above macro pastes an L
and a string argument together. In ASCII mode, there is no prefix to paste so it goes simply as:
#define __T(x) x
Note that you invoke this macro indirectly, via another macro -- _T()
(with a single underscore) and pass a string literal as argument.
#define T("x") "x"
That defines a macro function T
, and what would be a parameter named x
if there weren't any quotes. You could try something like this instead:
#define T(x) #x
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.