Tuesday, October 17, 2006

C99

Yesterday I was looking for the changes between the ANSI/ISO C (1989) and the new C99 (ISO 1999). The best information are found in: http://home.tiscalinet.ch/t_wolf/tw/c/c9x_changes.htm
Summary of the main changes:
  • external identifier now are case sensitive and up 31 characters (in old standard a portable program should not rely on case sensitiveness nor to more of 6 chars)
  • variable argument on macros
  • from C++: // comment, inline, declaration and statement can mix, for allow declaration in first "argument"
  • compound literals
  • initializers: int a[10] = { [5] = 3}; struct {int a,b} c = { .b=3};
  • long long (64-bit or longer) with LL, ll, ULL and ull suffixes in costants
  • __func__ "automatic variable" : void f(int void) { fprint("me is %s\n", __func__); }
  • _Bool and if you #include you have bool, true and false
  • restrict keyword to optimize function: you tell compiler that pointers don't point overlapping regions.
  • variable-length arrays
The gcc has a page about what is implemented and what not.

In http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899 you see the complete standard with the two corrigenda, and the rationale about the new standard. It worth to browse it!

No comments: