LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-12-2010, 05:46 PM   #1
searching_for_answers
Member
 
Registered: Sep 2009
Location: Sweden
Distribution: Mandriva
Posts: 44

Rep: Reputation: 21
C IDE which ignores C99?


Is there an IDE where I can write ANSI-C without complains and failures except ideone.com? Already tried NetBeans. I need it for K&R.

Last edited by searching_for_answers; 06-13-2010 at 07:30 AM.
 
Old 06-12-2010, 07:34 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by searching_for_answers View Post
Is there an IDE where I can write ASCI-C without complains and failures except ideone.com? Already tried NetBeans. I need it for K&R.
Isn't the behavior determined by the compiler switches ?

I do not use IDEs, but from command line that's the case.

And, IIRC, K&R != C89 - the latter is ANSI "C".
 
Old 06-12-2010, 08:44 PM   #3
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
As Sergei has said this has nothing to do with the IDE, rather the setting that you use for the compiler. Assuming that you are using gcc (or the IDE is) check the man pages to understand the most appropriate settings for your needs. Here is an online version which can be easier to navigate, look for -std= option.
 
Old 06-13-2010, 07:18 AM   #4
searching_for_answers
Member
 
Registered: Sep 2009
Location: Sweden
Distribution: Mandriva
Posts: 44

Original Poster
Rep: Reputation: 21
Quote:
Originally Posted by Sergei Steshenko View Post
Isn't the behavior determined by the compiler switches ?

I do not use IDEs, but from command line that's the case.
k


Quote:
And, IIRC, K&R != C89 - the latter is ANSI "C".
If (IIRC == "If I recall correctly")
C89 = "ANSI C";
printf("I don't understand what you're trying to say\n");
 
Old 06-13-2010, 07:27 AM   #5
searching_for_answers
Member
 
Registered: Sep 2009
Location: Sweden
Distribution: Mandriva
Posts: 44

Original Poster
Rep: Reputation: 21
Quote:
Originally Posted by graemef View Post
As Sergei has said this has nothing to do with the IDE, rather the setting that you use for the compiler. Assuming that you are using gcc (or the IDE is) check the man pages to understand the most appropriate settings for your needs. Here is an online version which can be easier to navigate, look for -std= option.
Code:
$gcc -std=c89
?
If that that is correct will it do any harm to Ubuntu since it uses C in other apps?
 
Old 06-13-2010, 08:11 AM   #6
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
compiling a program with an earlier C standard and then running it on Ubuntu will be fine. compiling Ubuntu using the old standard will most likely give you grief.
 
Old 06-13-2010, 08:29 AM   #7
searching_for_answers
Member
 
Registered: Sep 2009
Location: Sweden
Distribution: Mandriva
Posts: 44

Original Poster
Rep: Reputation: 21
Quote:
Originally Posted by graemef View Post
compiling a program with an earlier C standard and then running it on Ubuntu will be fine. compiling Ubuntu using the old standard will most likely give you grief.
So it works but I should not recompile Ubuntu before I change it back?
 
Old 06-13-2010, 09:46 AM   #8
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by searching_for_answers View Post
Code:
$gcc -std=c89
?
If that that is correct will it do any harm to Ubuntu since it uses C in other apps?
Compiling a new application has nothing to do wit already compiled ones.

Yes, ANSI "C" is also known as C89, so '-std=c89' is what you need.
 
Old 06-13-2010, 10:27 AM   #9
searching_for_answers
Member
 
Registered: Sep 2009
Location: Sweden
Distribution: Mandriva
Posts: 44

Original Poster
Rep: Reputation: 21
Solution

Code:
mattias@SNAR-PC-01:~/NetBeansProjects/Charater Counting$ cat programmet.c
#include<stdio.h>
main(){
    long nc;
    int c;
    nc = 0;
    while((c = getchar()) !=EOF)
        nc++;
    printf("%1d\n", nc);
Code:
mattias@SNAR-PC-01:~/NetBeansProjects/Charater Counting$ gcc -std=c89 -g -Wall programmet.c
programmet.c:2: warning: return type defaults to ‘int’
programmet.c: In function ‘main’:
programmet.c:8: warning: format ‘%1d’ expects type ‘int’, but argument 2 has type ‘long int’
programmet.c:9: warning: control reaches end of non-void function
Compiles it and -g add support for debugging and -wall will generate warnings. a.out is now created in the same directory as programmet.c

Code:
mattias@SNAR-PC-01:~/NetBeansProjects/Charater Counting$ ./a.out
Type this to run it.

This solves the thread but in the process I discovered that I actually don't need an ANSI-C IDE because there is nothing wrong with the code so far. EOF is Ctrl D not '\n'(enter) which I thought it was
FAIL


ideone.com is probably not ANSI-C the EOF is submit which explains why it works better than NetBeans.
 
Old 06-13-2010, 10:55 AM   #10
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by searching_for_answers View Post
...in the process I discovered that I actually don't need an ANSI-C IDE because there is nothing wrong with the code so far. ...
...

First of all, the wrong thing is your understanding of programming reality - as long as you see compiler warning and do nothing about them, thinking nothing is wrong with your code, your understanding of programming reality is wrong.

The very basic principle is: first make the code formally correct, i.e. with zero compiler warnings, and only then it might work.
 
  


Reply

Tags
ide


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Equivalent of std=c99 for C++ ? gnashley Programming 5 01-20-2010 05:09 PM
How to Use Type Identifiers as Function Parameters in C99? KareemSedki Programming 4 05-02-2008 11:45 AM
Compiler issue c99 sgriffiths Linux - Software 9 11-29-2006 03:23 AM
FC 5 install boot ignores ide=nodma option iusedtobeafox Fedora - Installation 2 04-14-2006 06:09 AM
C99 libs in ISO C++ ta0kira Programming 0 05-20-2005 02:12 AM


All times are GMT -5. The time now is 09:36 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration