Developer forums (C::B DEVELOPMENT STRICTLY!) > Contributions to C::B
Internalization, multi-line _T() and _() macros
maxblagaj:
Hi,
I have a generic question about multi-line _T() and _() macros.
So far I can see _T("abc") is converted to L"abc" which is ok for single line strings,
but if you have something like this:
_("first line"
"second line")
it gets converted to:
L"first line"
"second line"
which make my compiler bark about concatenation of incompatible strings.
The solution is easy -> I can just put the second line inside of another _T().
So the main question is if somebody sees any problems with this one?
I think there should be string extraction utility or something.
Regards,
Max.
stahta01:
Are you sure that you had trouble with _T(), I have only had issues with _() with MSVC or gcc 3.3 I can NOT remember which one. Which compiler are you using?
Tim S
maxblagaj:
gdb_driver.cpp
d:\work\codeblocks\src\plugins\debuggergdb\gdb_commands.h(323) : error C2308: concatenating mismatched strings
Concatenating wide "While setting up custom conditions for breakpoint %d (%s, line %d),
" with narrow "the debugger responded with the following error:
"
d:\work\codeblocks\src\plugins\debuggergdb\gdb_commands.h(323) : error C2308: concatenating mismatched strings
Concatenating wide "While setting up custom conditions for breakpoint %d (%s, line %d),
" with narrow "
Error: %s
"
d:\work\codeblocks\src\plugins\debuggergdb\gdb_commands.h(323) : error C2308: concatenating mismatched strings
Concatenating wide "While setting up custom conditions for breakpoint %d (%s, line %d),
" with narrow "Do you want to make this an un-conditional breakpoint?"
maxblagaj:
I've got it to build with MSVC 8. I can provide patches & project files for that if somebody is interested.
At the moment I just going though all my changes and thinking what can be reused without problems.
byo:
Solution is rather simple: When concatenating strings using _T() you
must put each string inside _T() macro:
--- Code: ---_T("First ") _T("Second")
--- End code ---
,
when using _(), you must put all strings inside one macro:
--- Code: ---_("First " "Second")
--- End code ---
At least that would conform to C++ specification of concatenating strings ;)
Regards
BYO
Navigation
[0] Message Index
[#] Next page
Go to full version