static TCHAR szWindowClass[] = L"foo";
L
is "glued" to the string "foo"
. How come? A function or a macro as I am used to is something like L("foo");
Can anyone explain me how come L be glued to the string?
noun. plural macros. Definition of macro (Entry 2 of 3) : a single computer instruction that stands for a sequence of operations.
The macro in C language is known as the piece of code which can be replaced by the macro value. The macro is defined with the help of #define preprocessor directive and the macro doesn't end with a semicolon(;).
(1) You can define a macro of a macro as in a macro containing another macro. (2) However, you cannot define a macro of a macro like #define INCLUDE #define STDH include <stdio.
L
is not a macro, it's just the standard prefix for wide (wchar_t
, "Unicode") string literals; the concept is similar to the L
suffix for long int
literals, f
suffix for float
literals and so on1.
By the way, if you are using TCHAR
s you shouldn't be using L
directly; instead, you should use the _T()
or TEXT()
macro, that adds L
at the beginning of the literal if the application is compiled "for Unicode" (i.e. TCHAR
is defined as WCHAR
), or adds nothing if the compilation target is "ANSI" (TCHAR
defined as CHAR
).
It's not a macro, it's a token that the compiler recognizes as a prefix that has some special meaning.
The same happens with e.g. l
as a suffix that produces long
literals, as in long x = 42l;
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With