09-28-2009, 08:29 PM #1
C Program Trouble Compiling w/GCC, Trouble Running in Xcode
- Member Since
- Jan 14, 2009
I wrote a C program that worked perfectly in Windows, but I am having trouble using Mac OS. In Windows I used DevC++ to compile and run the program.
When I tried to compile it in Xcode, it gave me an incorrect output. It kept giving me "inf" and "nan" for what I'm assuming is "infinite" and "not a number." It seems like it's not correctly calculating "eta" on line 121 of my source code (attached).
I thought it might be a compiler problem so I tried to compile it from the command line using gcc. I used the command:
gcc SLP.c -o SLP
It would not compile. This is the error I would get:
SLP.c:1:19: error: stdio.h: No such file or directory
SLP.c: In function ‘main’:
SLP.c:41: warning: incompatible implicit declaration of built-in function ‘printf’
It seems like there is a problem with my OS recognizing the stdio.h library. I've never had a problem with any C program with Xcode before. I did recently reinstall Xcode with the iPhone SDK. I want to reiterate that my program ran fine with DevC++ on Windows.
I've attached my code in case anyone wants to look at it. I had to attach it as a text file because a .c file would not upload. Just change the file extension. The correct final outputs should be w(0) = -4, w(1) = 2 and w(2) = 3.
09-28-2009, 10:41 PM #2
- Member Since
- May 03, 2009
- MBP 2.33 4GB: MacPro 8 Core 2.8, 16GB: MacMini 2.26 4GB: MacMin 2.53 4GB: iPhone3GS 32GB
I had no issues compiling and running your code via the command line or in XCode so it seems like your environment may be at issue from the CL. Also, you need to declare
to allow the abs function to be within the compilation scope to get the correct output. If you add this you should be all set.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
By raindroprainbow in forum OS X - Development and DarwinReplies: 10Last Post: 11-25-2012, 05:14 PM
By Chris23 in forum OS X - Development and DarwinReplies: 1Last Post: 11-23-2010, 07:51 PM
By Yuke14 in forum OS X - Apps and GamesReplies: 0Last Post: 05-13-2007, 02:36 PM
By jdgti in forum OS X - Development and DarwinReplies: 5Last Post: 09-20-2006, 05:08 AM
By meskue in forum OS X - Apps and GamesReplies: 0Last Post: 05-19-2006, 05:59 PM