On Mon, Aug 26, 2013 at 03:23:16PM -0700, Alex Wang wrote: > I found answer from here: > http://stackoverflow.com/questions/337449/how-does-one-declare-an-array-of-constant-function-pointers-in-c > > so if i understand it correctly: > > extern int (*build_assert(void))[1]; > > declare an extern function pointer 'build_assert', pointing to a function > that takes no input argument and returns int[1]. Right?
Not quite. You can use the "cdecl" program to see what this is: blp@sigsegv:~/ovs/_build$ cdecl Type `help' or `?' for help cdecl> explain extern int (*build_assert(void))[1]; declare build_assert as extern function (void) returning pointer to array 1 of int cdecl> blp@sigsegv:~/ovs/_build$ > But I'm still not clear why we must use (*build_assert(void))? I tried to > change it to normal variable declaration like below: > /* Build-time assertion for use in a declaration context. */ > #define BUILD_ASSERT_DECL(EXPR) \ > /* Build-time assertion for use in a declaration context. */ > #define BUILD_ASSERT_DECL(EXPR) \ > - extern int (*build_assert(void))[BUILD_ASSERT__(EXPR)] > + extern int build_assert[BUILD_ASSERT__(EXPR)] > > But I got "unused variable" warnings. So, is using "(*build_assert(void))" > for suppressing the "unused variable" warnings only? Yes, compilers do not ordinarily warn about functions that are declared but not called. The ideas behind BUILD_ASSERT come from gnulib. You can read the extensive documentation here: http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/verify.h;h=d42d0750ee13f2b1db1274b7db14079b77e8dbef;hb=HEAD The history of that file is also informative. _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev