<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>[WIN32] &#39;WinMain&#39; : function cannot be overloaded</title>
		<link>http://www.allegro.cc/forums/view/598938</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 20 Jan 2009 22:17:02 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Using Visual C++ Express, I created an empty win32 project (not console) and created the following as main.cpp:
</p><div class="source-code snippet"><div class="inner"><pre><span class="p">#include &lt;windows.h&gt;</span>

<span class="k1">int</span> main<span class="k2">(</span><span class="k2">)</span>
<span class="k2">{</span>
  <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="k2">}</span>

<span class="k1">int</span> APIENTRY WinMain<span class="k2">(</span>HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, <span class="k1">int</span> nCmdShow<span class="k2">)</span>
<span class="k2">{</span>
  <span class="k1">return</span> main<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

</p><div class="quote_container"><div class="title">Compiler said:</div><div class="quote"><p>
main.cpp(9) : error C2731: &#39;WinMain&#39; : function cannot be overloaded<br />    main.cpp(8) : see declaration of &#39;WinMain&#39;
</p></div></div><p>

Google didn&#39;t help in this case. Needless to say, neither did MSDN. This error occurs with both 2005 and 2008 versions.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Steve++)</author>
		<pubDate>Mon, 19 Jan 2009 16:31:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Get rid of the main() function.  That&#39;s for console, WinMain() is for gui app.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Roy Underthump)</author>
		<pubDate>Mon, 19 Jan 2009 16:33:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Roy, I&#39;ll dumb it down for you. The following code also produces a C2731:
</p><div class="source-code snippet"><div class="inner"><pre><span class="p">#include &lt;windows.h&gt;</span>

<span class="k1">int</span> APIENTRY WinMain<span class="k2">(</span>HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, <span class="k1">int</span> nCmdShow<span class="k2">)</span>
<span class="k2">{</span>
  <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Steve++)</author>
		<pubDate>Mon, 19 Jan 2009 16:41:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>When I tried the IDE in the Express versions, I couldn&#39;t create a gui app at all.  I thought it was to avoid cutting into the sales of the $$$ versions.  I just use makefiles.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Roy Underthump)</author>
		<pubDate>Mon, 19 Jan 2009 16:48:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It&#39;s not that hard to make a GUI app in Win32. Even easier with .NET WinForms.</p><p>I found the problem... I was using LPTSTR instead of LPSTR.</p><p>The reason I have a main() method called by WinMain is because I&#39;m making a &quot;magic main&quot; system similar to that of Allegro, except simplified for my purposes. I&#39;m actually using it in Ogre and Irrlicht, both of which I&#39;m currently evaluating.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Steve++)</author>
		<pubDate>Mon, 19 Jan 2009 16:50:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The only reason Microsoft did not use the regular main as the entry symbol of a C application is marketing: they feared that their code will be easily portable to other platforms.</p><p>This generated hundreds of &#39;magic main&#39; implementations and lots of boilerplate code to set things straight.</p><p>It was one of the dumbest things ever to be done by a software company.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (axilmar)</author>
		<pubDate>Mon, 19 Jan 2009 17:51:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hey, profit isn&#39;t dumb!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Steve++)</author>
		<pubDate>Mon, 19 Jan 2009 19:24:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Remember IBM&#39;s <a href="http://en.wikipedia.org/wiki/IBM_Personal_System/2">PS/2</a> and the proprietary bus interfaces?  That was an attempt to lock in customers also.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Roy Underthump)</author>
		<pubDate>Mon, 19 Jan 2009 21:17:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You don&#39;t need winmain.  You can just set SubSystem to Windows in msvc.  Then you have to set the entry point to mainCRTStartup.  Both are in the linker setting in project properties.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (torhu)</author>
		<pubDate>Mon, 19 Jan 2009 21:23:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I found the problem... I was using LPTSTR instead of LPSTR.
</p></div></div><p>
When I create a windows app I always use LPTSTR  and not LPSTR. Mind you, I always let MSVC set up my startup code...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Mon, 19 Jan 2009 21:53:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Steve++ said:</div><div class="quote"><p>

I found the problem... I was using LPTSTR instead of LPSTR.
</p></div></div><p>

</p><div class="quote_container"><div class="title">Neil Walker said:</div><div class="quote"><p>

When I create a windows app I always use LPTSTR and not LPSTR. Mind you, I always let MSVC set up my startup code...
</p></div></div><p>

I happened across this from a <a href="http://www.cplusplus.com/forum/beginner/3748/">thread</a> on the cplusplus.com forums :
</p><div class="quote_container"><div class="title">guestgulkan&#39;s reply said:</div><div class="quote"><p>

A bit more about windows string pointers.<br />I have counted 11 different type of string pointers in windows as follows;</p><p>...</p><p>LPTSTR      //LPWSTR if UNICODE defined, LPSTR if UNICODE not defined
</p></div></div><p>

I don&#39;t know if that&#39;s accurate or not, but maybe it has something to do with it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Tue, 20 Jan 2009 13:10:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thank god .net has a common type system <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Walker)</author>
		<pubDate>Tue, 20 Jan 2009 19:27:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thank god for .NET anyway, if only so we don&#39;t have to deal with winapi calls anymore.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Tue, 20 Jan 2009 21:58:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There is a way to get Visual Studio Express to create Win32 Gui apps. Google it, or use the 2008 version that has it enabled by default.:P
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Don Freeman)</author>
		<pubDate>Tue, 20 Jan 2009 22:17:02 +0000</pubDate>
	</item>
</rss>
