C99 the ISO standard C and GCC

This is a post on what is the actual C programming language.Its not gonna be a some sort of a tutorial or a how to just some clarifications for many friends of mine who predominantly use Turbo C to write program and “LET US C” to read.The C programming language was developed by K&R and it was a path breaking development.There were independent libraries and implementation by different compilers so it was decided to standardise C as POSIX was used to standardise UNIX.The standards released in the year 1989 are refered to us C89 standard,the latest ISO standard release is refered to us C99 the official ISO standard C.

As Indian institutions specify “Let us C” which never covers these issues students are kept ignorant of it.I actually heard of C99 from Joe and got the book The C complete reference book by hibert shild which covers the C99 standards in great detail.Common mis conceptions of a Turbo C programmer:

*There s nothing called the Conio,alloc.h(for malloc),dos.h,graphics.h in the ISO standard C language.

*Standard library methods are defined in stdlib.h which programmers should use.

*”Implicit int rule” never holds yet but i see quite a lot of aptitude questions based on this “ignorance is bliss” that is if  a function does not return a value it is implicitly returns an Integer this is not part of standard.

* There are many new and amzing features added to C99 this may raise some eyebrows:

->Inline functions are supported in C never say it as a difference between C and C++ to your     interviewer  you may land up in trouble if he knows C99 :-).

->Variables can be declared with in a block and they have no scope outside the block for              example the variables used in for loop can be declared using C++ style this makes code               maintainable.

for(int i=0;i<foo;i++) works in C++ :-). Simillarly you can declare variables with in If                block and while loops also.

->Variable length arrays are now available in C99 that is conventionally C compiler needs you to specify the size of an array the normal methodology followed is to declare an array of huge size wasting considerable amount of memory being wasted.So you declare something like this int a[100] to store some ten numbers.So now we have something called variable length arrays that is you can get the size at run time.

Like this : int foobar(int size)


int a[size];

return bar;

}  would work kickass right:-).So C is back with a bang.

*Why is people are unware of this is basically due to windoze addiction.Probably break your prejudice try out GNU C.GCC compiler can be used to compile a program in C99 standard as follows:

$ gcc -std=C99 -o foo foobar.c

This will compile the C program foobar.c in C99 standard.

*Another feature is we can mark a pointer as restrict its a qualifier used which will actually ensure that any access to the variable pointed through the restrict pointer can be accessed only through the particular pointer.

For eg: restrict const char *a=s;

Thus access  to s can only be through pointer *a*.This highly advantageous in certain case.Take for example the strcpy(char *src,char *dest) standard library function now what if src and dest point to the same variable the operation is undefined thus in C99 –> strcpy(restrict char * src,restrict char * dest) will ensure that they are different variables.

So use GNU/Linux or any UNIX its the time to grow up and say “I am not a kid anymore”.It s high point we use a standard compiler.


6 responses to “C99 the ISO standard C and GCC

  1. awesome post pal,
    very informative , u rock 🙂

  2. Good post. Agree with the necessity to use an industry standard compiler on a Unix to learn “C”.

    But the sad part about the C99 standard is that it is a PIG. A few parts of the standards are ambiguous and a lot of it is complicated.

    In fact so complicated that GCC is quite broken with respect to C99. The VLA (variable length array) that you mentioned is *very* fragile. GDB gets completely confused with VLAs ! Wide characters, unicode, extended integers, IEEE 60559 are all missing or broken.

    Sun Studio fares slightly better and has more completeness. But even it is not 100% C99 compliant AFAIK.

    But heck, I thought TCE ditched Turbo C ages back ? Couldn’t we do something to hasten the death of “Let us C” – “Turbo C” culture ?

    People should never program “C” on windows and “C++” on Unix 🙂

    C99 compliance status:

  3. “Let us C” is suggested by almost all colleges so yet an integer takes “two bytes”

    The disadvantage with The complete reference in C is that it does not have more programming examples.As many are new comers to programming “Let us C” gets the go ahead .Probably you can suggest to the committee which decides on the syllabus.

    Why is that C++ not to be programmed in UNIX :)?.

  4. A standard C++ ABI was never formally specified. Different Unixes have different standards and this leads to a lot of frustration if you try to build cross platform, compiler independent code.

    The situation is better in windows and mac because there is only one significant vendor and their standard holds – good or bad !


  5. Stephen Kochan’s “Programming in C” is the book I would recommend for “C”.

    But after 3 years outside college, my view right now is that “C” should not be the first programming language taught to a student. Scheme/Python/Ruby should be the first language.

    “C” should be taught after computer architecture and digital electronics but before operating systems.

  6. I learned C and C++ as one of my first languages, and it all made pretty good sense to me. I found old procedural programming much easier to learn than say, Ruby.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s