Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
Apple Computing Products:
macOS - Apps and Programs
C Program Trouble Compiling w/GCC, Trouble Running in Xcode
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="ebeccarayray" data-source="post: 916070" data-attributes="member: 82026"><p>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.</p><p></p><p>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).</p><p></p><p>I thought it might be a compiler problem so I tried to compile it from the command line using gcc. I used the command:</p><p></p><p>gcc SLP.c -o SLP</p><p></p><p>It would not compile. This is the error I would get:</p><p></p><p>SLP.c:1:19: error: stdio.h: No such file or directory</p><p>SLP.c: In function ‘main’:</p><p>SLP.c:41: warning: incompatible implicit declaration of built-in function ‘printf’</p><p></p><p>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.</p><p></p><p>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.</p><p></p><p>[ATTACH=full]11304[/ATTACH]</p></blockquote><p></p>
[QUOTE="ebeccarayray, post: 916070, member: 82026"] 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. [ATTACH=full]11304[/ATTACH] [/QUOTE]
Verification
Post reply
Forums
Apple Computing Products:
macOS - Apps and Programs
C Program Trouble Compiling w/GCC, Trouble Running in Xcode
Top