Precompiler replacements

Oct 19, 2010 at 1:19pm
Hello,

I am facing the following situation. In my code at a point I need to declare a std::wstring and compare it with a text "MessageBox" read from a file. e.g

if (filetext == L"MessageBox")
{
do something...
}

My problem is that the word MessageBox is defined as MessageBoxW in windows.h (I think) and the precompiler replaces the string with MessageBoxW. So I actually compare my text with MessageBoxW.

Is there any solution/trick to override this problem or do I have to change the text I use?

Thanks!
Last edited on Oct 20, 2010 at 9:02am
Oct 19, 2010 at 2:05pm
For Unicode, use std::wstring instead.
Oct 20, 2010 at 2:21pm

Sorry but i already use std::wstring (was writen false).
The code i use is:
#define IMPROVED_ENUM_NAME Flags
#define IMPROVED_ENUM_LIST ENUMITEM_VALUE(Log, 1) \
ENUMITEM_VALUE(ErrorLog, 2) \
ENUMITEM_VALUE(BoxMessage, 4) \
ENUMITEM_VALUE(TextMessage, 8) \
ENUMITEM_VALUE(Acknowledge, 16) \
ENUMITEM_VALUE(Reset, 32)
#include "defineImprovedEnum.h"

with "BoxMessage" instead of "MessageBox" works fine. Otherwise precompiler this that owns "MessageBox" and replace it with MessageBoxW because the Character Set is for unicode.
Last edited on Oct 20, 2010 at 2:22pm
Topic archived. No new replies allowed.