Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 29, 2012, 11: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 30, 2012, 12:07 AM   #2
xxcysxx
Thread Starter
macrumors 6502
 
Join Date: Oct 2011
nevermind
xxcysxx is offline   0 Reply With Quote
Old Dec 30, 2012, 11: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, 12:34 PM   #4
ArtOfWarfare
macrumors 603
 
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, 02: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, 02:19 PM   #6
gnasher729
In Time-Out
 
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

Similar Threads
thread Thread Starter Forum Replies Last Post
Important Xcode Question DavidBlack Mac Programming 5 Feb 25, 2013 01:46 PM
XCode - Cocoa-applescript question djjasonsa Mac Programming 3 Feb 21, 2013 04:50 PM
Very basic Xcode question jim51538 Mac Programming 2 Nov 13, 2012 02:00 PM
Question for those with ML GM and the new Xcode Amorino OS X 10.8 Mountain Lion 1 Jul 10, 2012 07:55 PM
xcode interface question osakamitsu iPhone/iPad Programming 6 Jun 17, 2012 07:57 PM

Forum Jump

All times are GMT -5. The time now is 11:53 AM.

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

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