New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus • Advice and insight from world-class Apple enthusiasts • Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Apps and Games Discussion of applications and games available for Mac OS X.

C Program Trouble Compiling w/GCC, Trouble Running in Xcode


Post Reply New Thread Subscribe

 
Thread Tools
ebeccarayray

 
Member Since: Jan 14, 2009
Posts: 6
ebeccarayray is on a distinguished road

ebeccarayray is offline
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.
Attached Files
File Type: txt SLP.txt (4.4 KB, 4 views)
QUOTE Thanks
wmprice1240

 
Member Since: May 03, 2009
Posts: 480
wmprice1240 has a spectacular aura about
Mac Specs: MBP 2.33 4GB: MacPro 8 Core 2.8, 16GB: MacMini 2.26 4GB: MacMin 2.53 4GB: iPhone3GS 32GB

wmprice1240 is offline
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

#include <stdlib.h>

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.
QUOTE Thanks

Post Reply New Thread Subscribe


« will software? | no iLife'08 in the replacement applications install DVD »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Torrent program trouble Yuke14 OS X - Apps and Games 0 05-13-2007 02:36 PM
Problem running a program off of a cd. Comic_Coder OS X - Operating System 1 04-05-2007 09:34 AM
Is there a Free program to run linux while running the Mac OS? Jonnyfive Running Windows (or anything else) on your Mac 4 10-04-2006 05:17 PM
XCode trouble meskue OS X - Apps and Games 0 05-19-2006 05:59 PM
Running a Linux program in OS X Matt OS X - Development and Darwin 8 01-02-2005 01:59 AM

All times are GMT -4. The time now is 08:24 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?