在使用linux中的双向链表的时候,遇到了typeof关键字的编译错误:
implicit declaration of function ‘typeof’
产生以上错误的原因在于-std=c99编译选项,typeof是gcc的扩展,并不在c99标准中,在gcc的文档中有详细的说明:
The typeof keyword is disabled by default when building with -std=c99as it's a GNU extension, make it known that it's an extension by usingthe underscore-enclosed variant.The underscore-encosed keyword is accepted by GCC without requestingextensions to the C99 standard, while the simpler typeof() keywordrequires GNU extensions to the C99 standard to be explicitly requested(e.g.: by using the -fasm option).ICC supports the __typeof__ keyword as well as typeof.
解决方法:
如果要启动该扩展,将编译选项-std=c99换成-std=gnu99即可。