Code::Blocks

User forums => Using Code::Blocks => Topic started by: caveman_1990 on September 06, 2010, 06:45:29 am

Title: Forcing ANSI C standard only.
Post by: caveman_1990 on September 06, 2010, 06:45:29 am
Hey,

I am currently studying C language at university and the lecture requires us to use "ANSI C standard" for our coding or else we will get a FAIL so can anyone please help me on how to setup code::blocks to use only ANSI C standard.

Thanks.

kevin
Title: Re: Forcing ANSI C standard only.
Post by: MortenMacFly on September 06, 2010, 07:20:36 am
Compile your code with the -ansi option, setup your compiler / project's compiler options accordingly.

However, still you should know what you are doing and what ANSI C actually means.
Title: Re: Forcing ANSI C standard only.
Post by: caveman_1990 on September 07, 2010, 03:13:12 am
Ok thanks for the help.
Title: Re: Forcing ANSI C standard only.
Post by: wrath on August 12, 2011, 09:33:36 am
Hey,

I am currently studying C language at university and the lecture requires us to use "ANSI C standard" for our coding or else we will get a FAIL so can anyone please help me on how to setup code::blocks to use only ANSI C standard.

Thanks.

kevin

Hey kevin did you get to change codeblock to use "ANSI C standard"? cause thats what i need at the moment
Title: Re: Forcing ANSI C standard only.
Post by: oBFusCATed on August 12, 2011, 11:02:23 am
Project -> Build options -> Compiler options -> Ansi bla bla...
Title: Re: Forcing ANSI C standard only.
Post by: codeur on August 12, 2011, 12:22:28 pm
Assuming that you use the GNU GCC Compiler:
For a supportive ansi C learning environment you will need to tick the following compiler flags in menu [Project]->[Build Options]:

- In C mode, support all ISO C programs...  [-ansi]
- Enable all compiler warnings... [-Wall]
- Enable warnings demanded by strict ISO C and... [-pedantic]

Never forget to create a project with these flags for every program that you build, even when there is only a single source code file in the project.

Alternatively:
If you always want this setup without having to set the flags for every new project, tick the same flags in the global compiler settings instead:
Go to menu [Settings]->[Compiler and debugger], then with the GNU GCC compiler selected, tick those same flags under the "Compiler Flags" tab.

@ Morten
Most C educational environments now use the ISO C99 standards instead of ansi.
The GCC flag -std=c99 is not available in the Codeblocks project build options and would be needed for those cases instead of -ansi.

I think that -std=c99 is worth adding to the compiler flag options for GCC and the equivalent for other compilers.
Title: Re: Forcing ANSI C standard only.
Post by: oBFusCATed on August 12, 2011, 02:58:01 pm
I disagree, they should also learn where to put the "other options" :)
Title: Re: Forcing ANSI C standard only.
Post by: codeur on August 13, 2011, 01:39:21 am
I disagree, they should also learn where to put the "other options" :)
That colleague of mine (C teacher) also thinks that they should learn to compile and link from the command line and learn to edit with vi.  :?
Title: Re: Forcing ANSI C standard only.
Post by: oBFusCATed on August 13, 2011, 01:58:06 am
He is wrong only about the last part :)
The compile and link part is really needed:)
Title: Re: Forcing ANSI C standard only.
Post by: codeur on August 13, 2011, 03:11:51 am
There is some truth in that oBFusCATed, but that teacher is not developing an IDE, you are.

However the beauty of open source is shown in action here. If some people think that a particular compiler flag is important for C programmers and an IDE developer does not want to make the flag available up-front in the IDE for whatever reason, these people can always add that flag, then distribute the modified IDE and the associated patch.
Title: Re: Forcing ANSI C standard only.
Post by: MortenMacFly on August 13, 2011, 06:40:30 am
@ Morten
Most C educational environments now use the ISO C99 standards instead of ansi.
The GCC flag -std=c99 is not available in the Codeblocks project build options and would be needed for those cases instead of -ansi.

I think that -std=c99 is worth adding to the compiler flag options for GCC and the equivalent for other compilers.
If you come up with a patch that would be nice. I am rather busy these days... but practically it should be a one-liner for each relevant compiler. It would be nice if you take other -std=XXX options into consideration, too... I don't know what else is available and makes sense.
Title: Re: Forcing ANSI C standard only.
Post by: codeur on August 29, 2011, 04:37:36 am
@ Morten,
Patch 003204 now on berliOS adds option flag -std=c99 to the GCC compilers GNUARM, GNUAVR, GNUMSP430, GNUPOWERPC, GNUTRICORE, MINGW.
This was overdue for C standards, but no other -std=XXX option makes sense at this point for C. The contemporary C++ standards are already well supported.
Title: Re: Forcing ANSI C standard only.
Post by: nickwelhar on April 03, 2015, 10:23:26 am
What is ANSI ?
 
ANSI (American National Standards Institute) codes are standardized numeric or alphabetic codes issued by the American National Standards Institute to ensure uniform identification of geographic entities through all federal government agencies. It has served as coordinator of the U.S. private sector, voluntary standardization system for more than 90 years. This is essentially an extension of the ASCII character set in that it includes all the ASCII characters with an additional 128 character codes. ASCII just defines a 7 bit code page with 128 symbols. ANSI extends this to 8 bit and there are several different code pages for the symbols 128 to 255. More about ANSI (http://net-informations.com/q/faq/encoding.html)

Nick
Title: Re: Forcing ANSI C standard only.
Post by: MortenMacFly on April 03, 2015, 12:19:30 pm
Nick
Are you a spammer? This is a thread dated back 2011. If you continue to make such non-sense posts you'll be banned.