Latest Tip; WinMain Error

Hi Jules,

Just got the latest tip, and now my project throws a compile error saying ‘WinMain’ : function cannot be overloaded

In case you’re wondering, I’m of course including Windows.h before the JuceHeader.h since I’ve not run into this issue until today.

For what it’s worth, the last time I pulled the latest tip was last Friday, and I didn’t have issues then.

This sounds to me like a mismatch between the Unicode declaration of WinMain using wide strings versus the ANSI declaration.

The issue was created/started at this commit:

https://github.com/julianstorer/JUCE/commit/18cfadf898aa1678dc6b092d4dd314ed082d567f

I think the issue lies within changes (aka Removals) to this file specifically: modules/juce_gui_basics/application/juce_Initialisation.h

New

int __stdcall WinMain (void*, void*, const char*, int)

Old

int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int)

Ah, I couldn’t remember why I had two different versions of that code hanging around, so cleaned it up. I guess the reason the old code was there is because otherwise it breaks if you’ve already included windows.h. Thanks, I’ll sort that out…

As it is written, it would seem the declaration of WinMain might break, since it is hard-coded to use a non-unicode string. To declare WinMain correctly for all values of the UNICODE project setting I think you want to use LPTSTR instead of LPSTR.

1 Like

Thanks Jules.

I must say that I’m confused about the differences between what you have there, and LPSTR and HINSTANCE… I totally thought those were char* and void* respectively…? Or is there some hidden unicode bs flag that affects this stuff?

…And you’ve just answered my question as I submitted my post, TheVinn. :smiley:

I’m using currently the commit tagged with 2.0.27.
This version does not work with unicode and Windows.h included. When I change the WinMain definition from

int __stdcall WinMain (HINSTANCE, HINSTANCE, const LPTSTR, int)

to

int __stdcall WinMain (HINSTANCE, HINSTANCE, const LPSTR, int)

it works again.

Ah, right… yes, it does look like it should just be an LPSTR, thanks!

Hi all,

I am running also into this issue, with the latest version of Juce (pulled today). Made a simple GUI app with the Introducer.

Is there something that I should explicitly set in the Introducer or in my VC++ 2010 project?

TIA.

Peter

Are you including Windows.h? If so, are you doing so before including JuceHeader.h?

Yep, thanks - I went through the other topics on this and got it fixed. Great framework, but steep learning curve :-)