pkulchenko / wxlua

wxlua: Lua bindings for wxWidgets cross-platform GUI toolkit; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and wxWidgets 3.x
304 stars 59 forks source link

VC projects contain excluding definitions _MBCS and UNICODE/_UNICODE. #41

Closed ValeryKV closed 4 years ago

ValeryKV commented 5 years ago

My env: Windows XP, VC 6.0, 32 bit, cmake 3.0, wxWidgets 3.0.4. I generated wxLua projects (wx static libs). They all contain both _MBCS and _UNICODE preprocessor definitions. _MBCS comes first and it seems the compiler uses it. There is no warning in compiler. When I added UTF-8 text to minimal.wx.lua, it was shown correctly. So I am just not sure it is a bug or not.

pkulchenko commented 5 years ago

I'm not sure what do you see as a potential bug. I build wxlua in the unicode build and haven't seen issues with showing the Unicode text (there are some problems with showing invalid Unicode text, as some controls (rightfully?) refuse to do it).

ValeryKV commented 5 years ago

I mean that wxLua.exe is built not as ANSI (not unicode). In the same time, utf-8 characters are shown correctly in the minimal sample. That is probably because wxWidgest was build with UNICODE. The fix could be by removing _MBCS from project files (.dsp) or I may close this issue.

pkulchenko commented 5 years ago

If you think the correct solution is to remove _MBCS from the project files and it works for you, please include the patch and I'll consider incorporating it. I don't have VS to test these changes.

This SO article has some interesting details on _MBCS vs _UNICODE. BTW, I couldn't find any references to _MBCS in the current wxlua code...

ValeryKV commented 5 years ago

Unfortunately, I do not know how cmake works and I do not know how to fix it. I retested it. I opened wxLua_Apps_wxLua.dsw after generation. Preprocessor definitions for wxLua_app is: WIN32,_DEBUG,_WINDOWS,_MBCS,LUA_COMPAT_ALL,UNICODE,_UNICODE,wxLUA_USEBINDING_WXADV=1,wxLUA_USEBINDING_WXAUI=1,wxLUA_USEBINDING_WXBASE=1,wxLUA_USEBINDING_WXCORE=1,wxLUA_USEBINDING_WXGL=1,wxLUA_USEBINDING_WXHTML=1,wxLUA_USEBINDING_WXMEDIA=1,wxLUA_USEBINDING_WXNET=1,wxLUA_USEBINDING_WXPROPGRID=0,wxLUA_USEBINDING_WXRICHTEXT=1,wxLUA_USEBINDING_WXSTC=1,wxLUA_USEBINDING_WXWEBVIEW=0,wxLUA_USEBINDING_WXXML=1,wxLUA_USEBINDING_WXXRC=1,CMAKE_INTDIR=\"Debug\",__WXDEBUG__

VC 6.0 takes _MBCS and compiles the project as ANSI with sizeof (TCHAR) equal to 1. wxWidgets was build as UNICODE with sizeof (TCHAR) equal to 2.

When I built all projects, I just deleted _MBCS. Not a big issue for me.

If it is not easy to fix (remove _MBCS) or not to spend time on VC 6.0, we may close this issue.

sonoro1234 commented 5 years ago

https://cmake.org/cmake/help/latest/command/remove_definitions.html

could do the work just after adding UNICODE

(It seems from some internet threads that _MBCS is always added in VC CMAKE generators!!!???)

also: according to https://stackoverflow.com/questions/7550388/how-do-i-set-the-taglib-character-set-on-windows-to-use-unicode

UNICODE and _UNICODE should be defined

pkulchenko commented 5 years ago

could do the work just after adding UNICODE

Right, remove_definitions(-D_MBCS) would probably work, but I don't see where _MBCS is being added in the first place. Am I missing it?

sonoro1234 commented 5 years ago

could do the work just after adding UNICODE

Right, remove_definitions(-D_MBCS) would probably work, but I don't see where _MBCS is being added in the first place. Am I missing it?

just add it after add_definitions(-D_UNICODE)

It seems from some internet threads that _MBCS is always added in VC CMAKE generators!!!???

pkulchenko commented 5 years ago

It seems from some internet threads that _MBCS is always added in VC CMAKE generators!!!???

That would explain it, as I don't see it added anywhere in wxlua... What file has add_definitions(-D_UNICODE)?

sonoro1234 commented 5 years ago

almost in https://github.com/pkulchenko/wxlua/blob/master/wxLua/build/FindwxWidgets.cmake#L627 but could not find add_definitions wxLua cmake is quite atypical!!!

pkulchenko commented 4 years ago

I'm not sure what to do about this, as I don't see what directives in the cmake file produce this result and how to avoid generating it.