Sunday, May 31, 2009

Notes of Learning C/C++ [01]

I decided to take some time to study C/C++ again during this summer. I planed to at least finish reading the book The C Programing Language, 2nd edition by Kernighan and Ritchie (refer to k&r).

The first note is about the version of C standard. People are talking about the ANSI C all the time. This is the C standard of USA. It's also widely referred as C89. ISO adopted this standard and named it ISO89 with some minor changes. It seems like that ANSI accepted this adoption. I would like to say that ANSI C is the most classic C standard. You can think of it as the intersection of all other C standard. C99 standard is the renewed version of C89 and has many new features. It adds several extensions with the consideration of the compatibility to C++. C99 is adopted by both ANSI and ISO so it's an official standard.

On the other hand, different C compilers support these standard with slight differences. The designers of the C compiler would like to add some unique features in order to facilitate their work under certain circumstance. For example, if you codes strictly follow the ANSI C standard (C89), you should have no troubles with any compiler on whatever platform. Here comes the tricky part. People actually feel like that C99 is more convenient (maybe!), especially those generations born after late 1980s. But some compilers support C99 very well while some not. For example, GCC, the pervasive compiler on Linux-related platforms, supports C99 well; while VC, the popular IDE on Windows platform, doesn't support C99. Keep this in mind while you are coding with non ANSI C, otherwise you will be frastrated.