Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 29, 2012, 10:48 PM   #1
xxcysxx
macrumors 6502
 
Join Date: Oct 2011
question about c++ in xcode

hello folks,

in visual studio i can just use

using namespace std;
int main()
{
return 0;
}

and in xcode i have to use

using namespace std;
int main(int argc, const char * argv[])
{

return 0;
}

for it to work? how come i cant do the main without any argument in the parenthesis like i did in visual studio?
i tried to do it and get compile failed.

i did use google to search but i only understand what the argument does, but i still don't understand why xcode requires it where as visual studio doesn't.

thanks for any inputs folks
xxcysxx is offline   0 Reply With Quote
Old Dec 29, 2012, 11:07 PM   #2
xxcysxx
Thread Starter
macrumors 6502
 
Join Date: Oct 2011
nevermind
xxcysxx is offline   0 Reply With Quote
Old Dec 30, 2012, 10:12 AM   #3
Biolizard
macrumors 6502
 
Join Date: May 2008
Location: London, United Kingdom
What some compilers allow you to get away with is quite shocking!
__________________
2009 2.66Ghz uMBP, iPhone 4S 32GB, 16GB WiFi iPad
Biolizard is offline   1 Reply With Quote
Old Dec 30, 2012, 11:34 AM   #4
ArtOfWarfare
macrumors 601
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
I generally write my C code in gEdit and then compile it by using make in Terminal... I'm pretty sure it'll compile without any arguments in main() just fine.
ArtOfWarfare is offline   0 Reply With Quote
Old Dec 30, 2012, 01:13 PM   #5
chrono1081
macrumors 604
 
chrono1081's Avatar
 
Join Date: Jan 2008
Location: Isla Nublar
? I never had to use them in Xcode. You *should* use them because its considered proper practice but most programming books omit them for some reason.
__________________
Mac Pro (2010): 3.33Ghz Intel Xeon (6 core) - 24 GB RAM - NVidia Quadro k5000
Macbook Air (2010): 2.13 Ghz Intel Core 2 Duo - 4GB RAM
chrono1081 is offline   0 Reply With Quote
Old Dec 30, 2012, 01:19 PM   #6
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
Most of the time when C++ code compiles on Windows and doesn't compile with either gcc or clang, it turns out that the code was illegal in the first place but some windows compiler still accepted it.
gnasher729 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting 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

Forum Jump


All times are GMT -5. The time now is 10:48 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC