Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Difference between int main and int main void in allegro

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Difference between int main and int main void in allegro
bamccaig
Member #7,536
July 2006
avatar

I like to explicitly declare void arguments. :) Just as I like to fully qualify instance members with this and class namespaces. >:( There's nothing wrong with it. In fact, I'd argue that it's better. You're being more explicit about what you want. There's less chance of you making a mistake that way.

Append:

char * [] is the most correct type for argv AFAIK. I'm not sure if people were saying that doesn't work on OS X (for whatever stupid reason) or if those people are just used to char ** (there's little practical difference).

Arthur Kalliokoski
Second in Command
February 2005
avatar

Are return registers demanded by C, or is it implementation defined?

Implementation defined, that's why he made that chart.

[EDIT]

Or maybe I should have said OS defined.

They all watch too much MSNBC... they get ideas.

Thomas Fjellstrom
Member #476
June 2000
avatar

In C you WANT to declare void arguments. In C++ it doesn't matter, but maybe makes it a bit clearer.

Implementation defined, that's why he made that chart.

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.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Arthur Kalliokoski
Second in Command
February 2005
avatar

So I assume most/all implementations for x86 do it that way? I would assume yes, just so they are somewhat compatible.

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 "red zone" (although you can ignore that if you want) etc.

They all watch too much MSNBC... they get ideas.

Thomas Fjellstrom
Member #476
June 2000
avatar

Windows also has a different calling convention for some things. But I don'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.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Arthur Kalliokoski
Second in Command
February 2005
avatar

{"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"}606547

They all watch too much MSNBC... they get ideas.

 1   2 


Go to: