C99が大変excellentで
ブロック途中での変数宣言とインライン関数がサポートされてるから、C++から乗り換えるのに困らないよね! さらに複合リテラルとか素敵だね。
// $gcc -std=c99 -Wall test.c #include <stdio.h> typedef struct { unsigned int x; unsigned int y; } point; void draw_string( const point* offset, const char* string) { // ブロックの途中での変数宣言 for (unsigned int y=0; y < offset->y; y++) printf("\n"); for (unsigned int x=0; x < offset->x; x++) printf(" "); if (string) printf("%s\n", string); } int main(void) { draw_string(&(point){ .x=10, .y=5 }, // 複合リテラル + 初期化指示子 "ほげほげ"); return 0; }
まあC99ならC++から乗り換え、というのはちょっと無理がある(RAIIやtemplateは捨て難い)。でも、Cが「嫌い」だった最大の理由が、変数の宣言位置の制約だったのでC99なら抵抗無く使えそう。
あと実はつい最近までC言語にはconstが無いと勘違いしてて、Cはありえんとか思ってた。お前がありえん(笑)