How to make a preprocessor string that works with both narrow and wide

I need to create two projects with different names. Both projects will have the same code.

So, I started replacing the places that call the old name with a preprocessor in stdafx.h called APP_NAME

In stdafx.h I put

#define APP_NAME _T("My name") 

And when I find code like

function(parm1,_T("My old name have a error"));

I want to replace

function(parm1, APP_NAME _T(" have a error"));

But when mixing wide (T ("x") or L "), many errors appear with pure narrow (" ")

error C2308: concatenation of inconsistent strings

Can any preprocessing magic be used to overcome it?

+5
source share
4 answers

, , APP_NAME, NAME . , _T ( "..." ), ( , _T ).

+2

_T , , , .

#define APP_NAME "My name"
function(parm1, _T(APP_NAME) _T(" have a error"));

, Visual ++ 2010. ++ 0x , ( [lex.string]):

6 (2.2) . , . , , . UTF-8 , . , . [. , . 6 ( , ), . - ]

+2

APP_NAME APP_NAME_W, . , .

0

. , _T(), . , UNICODE, , _T() " L" ".

0

All Articles