tnntnn
tnntnn

Reputation: 13

how can C++ macro use for two string literal

I used these macros before:

#define TEXT_A   _T("a")
#define TEXT_B   _T("b")

std::wstring text = TEXT_A TEXT_B;      // then text = "ab"

now how can i do this:

#define TEXT_A   "a"
#define TEXT_B   "b"
std::wstring text = _T(TEXT_A TEXT_B);     // i need text be "ab" but failed.  and that error is wchar_t cannot connect with char.

I'm looking for a macro to do that.

Upvotes: 1

Views: 577

Answers (1)

Yakov Galka
Yakov Galka

Reputation: 72479

Use

std::wstring text = _T(TEXT_A) _T(TEXT_B);

Even a better solution: stop using wstring.

Upvotes: 1

Related Questions