Reading C type declarations(引用http://unixwiz.net/techtips/reading-cdecl.html)

Even relatively new C programmers have no trouble reading simple C declarations such as

int      foo[5];     // foo is an array of 5 ints
char    *foo;        // foo is a pointer to char
double   foo();      // foo is a function returning a double

but as the declarations get a bit more involved, it's more difficult to know exactly what you're looking at.

char *(*(**foo[][8])())[]; // huh ?????

It turns out that the rules for reading an arbitrarily-complex C variable declaration are easily learned by even beginning programmers (though how to actually use the variable so declared may be well out of reach).

This Tech Tip shows how to do it.

 

 

我们经常会遇到复杂的C声明,对于如何阅读这些声明,这里记录了一篇外文,写的很好,值得阅读。

http://unixwiz.net/techtips/reading-cdecl.html

posted @ 2015-03-16 09:49  软跋涉者  阅读(125)  评论(0编辑  收藏  举报