Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

wxUSE_UNICODE

0 views
Skip to first unread message

Matt Gregory

unread,
May 25, 2003, 2:25:05 AM5/25/03
to
When is it appropriate to turn this on? I have been compiling Unicode
and mine is still set to zero. If I use this, does that mean I can no
longer compile ANSI? Do I have to use wxUSE_UNICODE for Unicode builds
and turn it off for ANSI builds of wxWindows?

Thanks!
Matt Gregory

P.s. Incidentally, I was trying to answer these questions and I came across
this in arrimpl.cpp:

// VC++ can't cope with string concatenation in Unicode mode
#if defined(wxUSE_UNICODE) && wxUSE_UNICODE
#define _WX_ERROR_REMOVE2(x) wxT("bad index in ::RemoveAt()")
#else
#define _WX_ERROR_REMOVE2(x) wxT("bad index in " #x "::RemoveAt()")
#endif

I don't know if anyone cares, but this isn't quite correct. VC++ can
concat strings in Unicode mode, it just can't concat a Unicode string
with an ANSI string. The preprocessor does macro expansion before it
does string concatenation, apparently. Thus:

#define _WX_ERROR_REMOVE2(x) wxT("bad index in ") wxT(#x) wxT("::RemoveAt()")

Matt Gregory

unread,
May 29, 2003, 9:03:37 AM5/29/03
to
Thanks for the reply!

Vadim Zeitlin wrote:
> On Sun, 25 May 2003 06:25:05 GMT Matt Gregory <msgr...@earthlink.net> wrote:
>
> MG> When is it appropriate to turn this on?
>
> When you want to build the library in Unicode :-)
>
> MG> I have been compiling Unicode and mine is still set to zero.
>
> If UNICODE or _UNICODE is defined (as it is on the command line in the
> Unicode configurations of the VC++ project files), then wxUSE_UNICODE gets
> defined automatically in wx/wxchar.h.

Ah, I didn't know that.


> MG> If I use this, does that mean I can no longer compile ANSI?
>
> Sorry, I don't quite understand this question?

I'm asking because if you enable wxUSE_UNICODE in the original setup.h, and
build all eight configurations, you're going to have eight unicode builds
instead of four ANSI and four Unicode. If you don't enable it, then you
would ostensibly have eight ANSI builds, but since it defines _UNICODE
automatically, that's not true. I think wxUSE_UNICODE should be abandoned
in favor of plain old _UNICODE. Unless it exists for cross platform
compatibility, I just don't see the point of having wxUSE_UNICODE if it is
just an alias for _UNICODE, especially if it can't be set in the global
configuration file unless you never want to build ANSI. I think if
wxUSE_UNICODE is needed it should not be included in the global configuration
file, but should be defined on a project-by-project basis like __WXDEBUG__.

Anyway, that's why I was so confused about it.


> MG> P.s. Incidentally, I was trying to answer these questions and I came across
> MG> this in arrimpl.cpp:
> MG>
> MG> // VC++ can't cope with string concatenation in Unicode mode
> MG> #if defined(wxUSE_UNICODE) && wxUSE_UNICODE
> MG> #define _WX_ERROR_REMOVE2(x) wxT("bad index in ::RemoveAt()")
> MG> #else
> MG> #define _WX_ERROR_REMOVE2(x) wxT("bad index in " #x "::RemoveAt()")
> MG> #endif
> MG>
> MG> I don't know if anyone cares, but this isn't quite correct. VC++ can
> MG> concat strings in Unicode mode,
>
> Normally you're right but I think I had some strange problems in this
> specific situation. Maybe I just did some stupid mistake however and it
> wasn't really its fault -- I didn't spend much time on this to be honest.
>
> MG> it just can't concat a Unicode string with an ANSI string.
>
> At least in this respect it doesn't differ from any other ANSI C/C++
> compiler ;-)
>
> MG> The preprocessor does macro expansion before it does string
> MG> concatenation,
>
> Yes, as above.

Yeah, I thought about this after I posted it and realized that it would be
impossible for the preprocessor to do concatenation before macro expansion.
Not to mention the compiler is what concatenates strings, but I didn't know
that until I looked it up.

>
> MG> #define _WX_ERROR_REMOVE2(x) wxT("bad index in ") wxT(#x) wxT("::RemoveAt()")
>
> Could you try if this works? If it does, we should change the sources but
> I _think_ it didn't for me.

It works with VC6.0.

Matt Gregory

0 new messages