<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Difference between int main and int main void in allegro</title>
		<link>http://www.allegro.cc/forums/view/610926</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 03 Sep 2012 22:00:54 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I want to know what is the difference between int main() and int main(void) in an allegro program. <br />If there are any other alternatives, please explain.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AleX-G Squadron)</author>
		<pubDate>Thu, 30 Aug 2012 17:53:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There is no difference. And that&#39;s basic c/c++, not allegro-specific.</p><p>You can also have int main(int argc, char* argv[]), which accepts command-line parameters. argc is the amount of arguments, argv is the array of arguments, with the first one being the program name.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (J-Gamer)</author>
		<pubDate>Thu, 30 Aug 2012 17:58:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/610926/964440#target">J-Gamer</a> said:</div><div class="quote"><p> There is no difference. And that&#39;s basic c/c++, not allegro-specific.</p></div></div><p>In C++, the standards state the void should be omitted.  The C++ standards also makes the names argc and argv mandatory, but in C, you can call them whatever you want.  Most C++ compilers probably do allow this anyway, even though it&#39;s not following the standard.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Thu, 30 Aug 2012 18:04:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There is a difference in Allegro terms <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />. Always use int main(int argc, char **argv). On Mac and maybe iOS it&#39;s required in C++ programs. You can&#39;t compile with int main(void).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Thu, 30 Aug 2012 18:08:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>For the most part, how you define your main is up to if you need command line arguments, or just how lazy you are feeling at the time.</p><p>Allegro has requirements for main to work on OS X, (and perhaps other platforms). The required form is <span class="source-code"><span class="k1">int</span> main<span class="k2">(</span><span class="k1">int</span> argc, <span class="k1">char</span> <span class="k3">*</span><span class="k3">*</span>argv<span class="k2">)</span></span>.</p><p>I have no idea where the docs tell the user, but I remember it from discussions in past threads.</p><p>Edit:<br />Slow Hippo is Slow
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Timorg)</author>
		<pubDate>Thu, 30 Aug 2012 18:11:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok, thanks for replies! <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AleX-G Squadron)</author>
		<pubDate>Thu, 30 Aug 2012 19:10:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/610926/964441#target">LennyLen</a> said:</div><div class="quote"><p>The C++ standards also makes the names argc and argv mandatory</p></div></div><p>Really?  That&#39;s pretty surprising, considering you don&#39;t have to use the same argument names in .h declaration and the .cpp definition.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Karadoc ~~)</author>
		<pubDate>Thu, 30 Aug 2012 19:31:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/610926/964460#target">Karadoc ~~</a> said:</div><div class="quote"><p> Really?</p></div></div><p>Yup.</p><p><a href="http://www-d0.fnal.gov/~dladams/cxx_standard.pdf">http://www-d0.fnal.gov/~dladams/cxx_standard.pdf</a></p><p>Section 3.6.1 paragraph 2
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Thu, 30 Aug 2012 23:38:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hmm...</p><p>Well, that doesn&#39;t explicitly say that those particular names are required; but I can see why people might think that the strict technical meaning may allow particular implementations to disallow different argument names..</p><p>But I still doubt that was the intended meaning of the document; and I&#39;m not completely convinced that it is even the strict technical meaning! (I&#39;m actually reading <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf">this version</a> now, because I figure it&#39;s more up-to-date; and I&#39;m scanning through other sections to see whether it says that the particular variable names are unimportant in function definitions.</p><p>I notice that in 8.3.5 (of the document I linked to) it says</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>The parameter list (void) is equivalent to the empty parameter list.</p></div></div><p>So to me that implies <span class="source-code"><span class="k1">int</span> main<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span></span> is ok.</p><p>And ... </p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>After<br />determining the type of each parameter, any parameter of type “array of T” or “function returning T” is adjusted to be “pointer to T” or “pointer to function returning T,” respectively.</p></div></div><p> ... could imply <span class="source-code"><span class="k1">int</span> main<span class="k2">(</span><span class="k1">int</span> argc, <span class="k1">char</span><span class="k3">*</span><span class="k3">*</span> argv<span class="k2">)</span></span> is allowed...</p><p>In any case, despite the possible technicalities, I&#39;d still be pretty comfortable renaming argc and argv if I wanted to – but I don&#39;t think I&#39;d ever have a good reason to do so anyway.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Karadoc ~~)</author>
		<pubDate>Fri, 31 Aug 2012 05:32:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/610926/964517#target">Karadoc ~~</a> said:</div><div class="quote"><p> Well, that doesn&#39;t explicitly say that those particular names are required</p></div></div><p>My interpretation of it is that those two forms are the only two forms that MUST be accepted, and that other forms are optional.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p> In any case, despite the possible technicalities, I&#39;d still be pretty comfortable renaming argc and argv if I wanted to – but I don&#39;t think I&#39;d ever have a good reason to do so anyway.</p></div></div><p>Ditto.  GCC and MSVC++ both allow things that aren&#39;t in the standards, and they&#39;re the two most widely used compilers.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (LennyLen)</author>
		<pubDate>Fri, 31 Aug 2012 05:37:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Its bad style to do int main(void). My Comp Sci I professor would kill me if he saw me still using int main (void) or even worse, void main(void).</p><p><img src="http://www.allegro.cc/forums/smileys/cheesy.gif" alt=";D" border="0" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ted_gress)</author>
		<pubDate>Sun, 02 Sep 2012 00:41:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I am sure someone will correct me if I any of these points are wrong...</p><p><span class="source-code"><span class="k1">int</span> main<span class="k2">(</span><span class="k2">)</span></span> and <span class="source-code"><span class="k1">int</span> main<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span></span> are actually different. The 1st says the number of arguments is unspecified (implicit), where the 2nd one says that there is none (explicit).</p><p>If a type is not specified in C it assumes that its an <span class="source-code"><span class="k1">int</span></span>. So <span class="source-code">main<span class="k2">(</span><span class="k2">)</span></span> assumes that the return value is an int. Where <span class="source-code"><span class="k1">void</span> main<span class="k2">(</span><span class="k2">)</span></span> says that main does not return a value, operating systems get quite upset when main doesn&#39;t return anything.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Timorg)</author>
		<pubDate>Sun, 02 Sep 2012 18:03:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/610926/964789#target">Timorg</a> said:</div><div class="quote"><p>
int main() and int main(void) are actually different. The 1st says the number of arguments is unspecified (implicit), where the 2nd one says that there is none (explicit).
</p></div></div><p>
That&#39;s only true in C. In C++, f() is equivalent to f(void).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Oscar Giner)</author>
		<pubDate>Sun, 02 Sep 2012 18:07:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Void functions always &quot;return&quot; something, but it&#39;s probably random garbage.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Sun, 02 Sep 2012 20:21:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/610926/964794#target">Arthur Kalliokoski</a> said:</div><div class="quote"><p>Void functions always &quot;return&quot; something, but it&#39;s probably random garbage</p></div></div><p>I&#39;m not so sure about that. The return value is passed on the stack normally (afaik). The compiler should be free to omit the stack push/pop for a return value if the function is declared as &quot;returning&quot; void.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Sun, 02 Sep 2012 22:59:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I thought they were normally stored in the EAX register if they fitted.<br />But I&#39;m not sure.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (l j)</author>
		<pubDate>Sun, 02 Sep 2012 23:37:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well then all my assembly code is wrong.  OTOH, it works fine.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Mon, 03 Sep 2012 10:24:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It has always been a mystery to me what main should return.<br />So I finally googled.</p><p><a href="http://stackoverflow.com/questions/204476/what-should-main-return-in-c-c">http://stackoverflow.com/questions/204476/what-should-main-return-in-c-c</a><br />&quot;I believe that main() should return either EXIT_SUCCESS or EXIT_FAILURE. They are defined in stdlib.h&quot;</p><p>Only useful if your program is used by another program. As far as I know, the OS doesn&#39;t care what programs return.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trezker)</author>
		<pubDate>Mon, 03 Sep 2012 10:34:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If there&#39;s more than 1 potential error state, it should return a different non-zero value for each. For something that either works or doesn&#39;t, then sure, EXIT_SUCCESS and EXIT_FAILURE are good.</p><p>EDIT: Though the actual range of values that can be returned differs between operating systems. I think some only go from 0 to 255.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Mon, 03 Sep 2012 11:20:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The value returned by main is used as an exit code for the process. But exit codes are only 8-bits on all OSes where I&#39;ve seen them firsthand (DOS/Windows and several Unixes) so only the low 8 bits are preserved.<br />The most important convention is return 0 on success and non-zero on failure, but it only actually matters if whatever runs your program cares about it :<br />For example if you set up your program to run using Windows&#39;s scheduler, after execution the log will mark it &quot;failed&quot; if the return code wasn&#39;t zero.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Audric)</author>
		<pubDate>Mon, 03 Sep 2012 13:53:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/610926/964739#target">ted_gress</a> said:</div><div class="quote"><p>Its bad style to do int main(void).</p></div></div><p>
Nonsense.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>My Comp Sci I professor would kill me if he saw me still using int main (void) or even worse, void main(void).</p></div></div><p>
<span class="source-code"><span class="k1">void</span> main<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span></span> isn&#39;t proper C and he&#39;d be right to kill you (or at least look at you very sternly) for using it. <span class="source-code"><span class="k1">int</span> main<span class="k2">(</span><span class="k1">void</span><span class="k2">)</span></span> is perfectly fine.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/610926/964810#target">Thomas Fjellstrom</a> said:</div><div class="quote"><p>The return value is passed on the stack normally (afaik). The compiler should be free to omit the stack push/pop for a return value if the function is declared as &quot;returning&quot; void.</p></div></div><p>
Depends, I think.</p><p>I&#39;m sure this used to be true back when I was looking at 16 bit DOS assembly. I&#39;m also fairly sure you&#39;re supposed to use rax (eax, ax, al, whatever) in 64 bit assembly. I&#39;m far less sure about 32 bit, but I <i>think</i> it&#39;s supposed to be eax there as well.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Mon, 03 Sep 2012 14:50:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>From an Agner Fog pdf.</p><p><span class="remote-thumbnail"><span class="json">{"name":"606545","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/b\/9bf3d5b0ae0cd879ea7c9b6a7a924015.png","w":873,"h":571,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/b\/9bf3d5b0ae0cd879ea7c9b6a7a924015"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/9/b/9bf3d5b0ae0cd879ea7c9b6a7a924015-240.jpg" alt="606545" width="240" height="156" /></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Mon, 03 Sep 2012 21:11:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ah, so register first, then stack if needed. I thought using a register was just an optimization C compilers liked to do, and the stack was the <i>proper</i> place for it. At least on x86 where there is no dedicated return register.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 03 Sep 2012 21:32:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There&#39;s no stack in the usual sense mentioned there.  ST(0) etc. are the &quot;stack&quot; on the floating point coprocessor, the XMMx stuff are the SSE registers.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Mon, 03 Sep 2012 21:38:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Oh, really? Huh.</p><p>Are return registers demanded by C, or is it implementation defined?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 03 Sep 2012 21:39:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I like to explicitly declare <span class="source-code"><span class="k1">void</span></span> arguments. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /> Just as I like to fully qualify instance members with <span class="source-code"><span class="k1">this</span></span> and class namespaces. <img src="http://www.allegro.cc/forums/smileys/angry.gif" alt="&gt;:(" /> There&#39;s nothing wrong with it. In fact, I&#39;d argue that it&#39;s better. You&#39;re being more explicit about what you want. There&#39;s less chance of you making a mistake that way.</p><p><b>Append:</b></p><p><span class="source-code"><span class="k1">char</span> <span class="k3">*</span> <span class="k2">[</span><span class="k2">]</span></span> is the most correct type for <span class="source-code">argv</span> AFAIK. I&#39;m not sure if people were saying that doesn&#39;t work on OS X (for whatever stupid reason) or if those people are just used to <span class="source-code"><span class="k1">char</span> <span class="k3">*</span><span class="k3">*</span></span> (there&#39;s little practical difference).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Mon, 03 Sep 2012 21:41:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/610926/964880#target">Thomas Fjellstrom</a> said:</div><div class="quote"><p> Are return registers demanded by C, or is it implementation defined?</p></div></div><p>Implementation defined, that&#39;s why he made that chart.</p><p>[EDIT]</p><p>Or maybe I should have said OS defined.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Mon, 03 Sep 2012 21:44:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>In C you WANT to declare void arguments. In C++ it doesn&#39;t matter, but maybe makes it a bit clearer.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/610926/964884#target">Arthur Kalliokoski</a> said:</div><div class="quote"><p>Implementation defined, that&#39;s why he made that chart.</p></div></div><p>I see, good to know. So I assume most/all implementations for x86 do it that way? I would assume yes, just so they are somewhat compatible.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 03 Sep 2012 21:44:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/610926/964885#target">Thomas Fjellstrom</a> said:</div><div class="quote"><p> So I assume most/all implementations for x86 do it that way? I would assume yes, just so they are somewhat compatible.</p></div></div><p>Yes, although there are tons of other gotchas, such as Windows requiring prepended underscores on globals in the assembly code but not the C code, Linux has the &quot;red zone&quot; (although you can ignore that if you want) etc.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Mon, 03 Sep 2012 21:49:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Windows also has a different calling convention for some things. But I don&#39;t know if that affects the return. The underscore thing just just part of the object/binary spec. COFF demands an leading underscore. Even C compilers add the underscore in the compiled code.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 03 Sep 2012 21:51:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><span class="remote-thumbnail"><span class="json">{"name":"606547","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/d\/9d61580b64b73c2a6f341b02584456f0.png","w":1236,"h":1316,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/d\/9d61580b64b73c2a6f341b02584456f0"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/9/d/9d61580b64b73c2a6f341b02584456f0-240.jpg" alt="606547" width="240" height="255" /></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Mon, 03 Sep 2012 22:00:54 +0000</pubDate>
	</item>
</rss>
