Please add wWinMain() to juice_Initialization.h


#1

Compiling under MinGW-64 with UNICODE support (-municode linker flag) requires wWinMain as the entry point to the executable.

Both UNICODE and _UNICODE are defined in my project. 

I use the following workaround for now (juice_Initialization.h, from line 96) 

  #if defined (WINAPI) || defined (_WINDOWS_)
   #define JUCE_MAIN_FUNCTION       int __stdcall WinMain (HINSTANCE, HINSTANCE, const LPSTR, int)
  #elif defined (UNICODE)
   #define JUCE_MAIN_FUNCTION       int __stdcall wWinMain (void*, void*, const wchar_t*, int)
  #elif defined (_UNICODE)
   #define JUCE_MAIN_FUNCTION       int __stdcall WinMain (void*, void*, const wchar_t*, int)
  #else
   #define JUCE_MAIN_FUNCTION       int __stdcall WinMain (void*, void*, const char*, int)
  #endif

Thanks.


#2

I don't have a mingw-64 build to work with - could you suggest some #ifdefs that will only be present when doing a mingw-64 build? For example, a cleaner approach might be to leave the existing defines, but add

#if [some kind of mingw64 flag]
 #define WinMain wWinMain 
#endif

 


#3

I would suggest something like this:

 #if JUCE_MINGW && UNICODE
   #ifdef JUCE_MAIN_FUNCTION
     #undef JUCE_MAIN_FUNCTION
   #endif
   #define JUCE_MAIN_FUNCTION       int __stdcall wWinMain (void*, void*, const wchar_t*, int)
 #endif

JUCE_MINGW is already defined in juce_TargetPlatform.h (#ifdef __MINGW32__ , line 87)

Thanks.


#4

Surely that'd be active for a 32-bit build too? I thought you meant that this was only needed for a 64-bit build?

And what about my suggestion to redefine WinMain instead? Seems like that'd be less repeated code.


#5

Yes, this define is set to 1 when compiling under mingw-64 in 64-bit mode. I do build for both 32 and 64 archs at the same time. 

My build system has two separate toolchains for each arch:

  • GCC 4.8.1, Mingw-w64 ver 3.1.0,  Target: x86_64-w64-mingw32
  • GCC 4.8.1, Mingw-w64 ver 3.1.0,  Target: i686-w64-mingw32 

You're right, putting the define as you've suggested in the main file just before START_JUCE_APPLICATION solves the problem. So, no need to change the library code. Thank you for your help!