Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Jaguar Dev Tools (c++) and main ()

Jaguar Dev Tools (c++) and main ()
Thread Tools
Dedicated MacNNer
Join Date: Oct 2000
Status: Offline
Reply With Quote
Sep 9, 2002, 10:42 PM
 
Has anyone noticed that c++ (that is, the compiler, not the language) requires main to be declared with an "int" return type with the new compiler version?

It doesn't make any difference to me since, by habit, I use an int return type. But I'm taking a class where I have to modify the instructor's program, and his code uses voids, and that's where I noticed this.

I modified an assignment I did last semester (with the December tools) which worked last month. I changed from "int main (void)" to "void main (void) and I got the compiler complaint that "'main' must return int".

I'm busy with school and don't have much time to look into this, so I'm just making this observation since I haven't seen it posted in any threads. (I'm not currently a CS major so it's not a high priority for me.)
(Last edited by skipjack; Sep 9, 2002 at 11:53 PM. )
     
Forum Regular
Join Date: May 2001
Status: Offline
Reply With Quote
Sep 9, 2002, 10:44 PM
 
Years ago the standard changed to require int as return from main(). Though many compilers still support void, newer compilers will yell at you.
If your computer stops responding for a long time, turn it off and then back on. - Microsoft
     
Dedicated MacNNer
Join Date: Mar 2001
Location: Iowa City, IA
Status: Offline
Reply With Quote
Sep 10, 2002, 01:49 PM
 
Actually, the C standard has never allowed any other return type. Pre-Standard, Ritchie's reference compiler returned int: As is true now, any function declared without a return type implicitly returns int, so "main()" is the same as "int main()".

void main() is a useless extension that is unaccountably popular with some people. Follow the compiler's advice.
James

"I grew up. Then I got better." - Sea Wasp
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:46 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2