Preprocessor question
-
How can I use string constant as parameter to function requiring wchar_t* ?
#define MYSTR "abc"
// #define MYSTRW L"abc" // I don't like this solution because I have to update the same 2 stringswstring x(MYSTR); // error C2664
thank you
This
MAKELONG
macro definition will work for you.#include <string>
#define MYSTR "abc"
#define MAKELONG2(S) L##S
#define MAKELONG(S) MAKELONG2(S)std::wstring a(MAKELONG(MYSTR));
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
How can I use string constant as parameter to function requiring wchar_t* ?
#define MYSTR "abc"
// #define MYSTRW L"abc" // I don't like this solution because I have to update the same 2 stringswstring x(MYSTR); // error C2664
thank you
use
#define MYSTR _T("abc")
and then accordingly define (or not) the
UNICODE
symbol. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
This
MAKELONG
macro definition will work for you.#include <string>
#define MYSTR "abc"
#define MAKELONG2(S) L##S
#define MAKELONG(S) MAKELONG2(S)std::wstring a(MAKELONG(MYSTR));
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
great, thank you :-D I was trying just 1st macro before and I was getting the macro's name in my string :laugh:
Yup - been there, done that :-)
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p