linux kernel 编译的时候报错:expected specifier-qualifier-list before
转载:
http://hi.baidu.com/wwssttt/item/edaa423696b7c5c72e8ec2ae
在oc中经常会遇到expected specifier-qualifier-list before sth之类得编译错误,造成这种错误得主要原因就是使用了未被定义的变量。关于specifier-qualifier-list的定义:It's a list of specifiers and qualifiers :-) Specifiers are things like void, char, struct Foo, etc., and qualifiers are keywords like const and volatile. See this C grammar for the definition.如:
typedef struct {
char *key;
long canTag;
long canSet;
long allowMultiple;
confType *next;
} confType;
由于confType未被完全定义即在定义中使用,这样就会报错,常规得解决办法有:
1. typedef struct confType {
char *key;
long canTag;
long canSet;
long allowMultiple;
struct confType*next;
} confType;
2.
typedef structconfType confType;
struct confType {
char *key;
long canTag;
long canSet;
long allowMultiple;
confType *next;
};
上述例子可参考
http://stackoverflow.com/questions/2894639/what-is-a-specifier-qualifier-list
http://stackoverflow.com/questions/3888569/expected-specifier-qualifier-list-before
在实际实验过程中会发现还会有一种方法可以解决此问题:
假如有一个ParserDemo工程,而其中有ParserDemoAppDelegate.h/ParserDemoAppDelegate.m和ParserDemoViewController.h/ParserDemoViewController.m. 有时候为了使用C++代码,经常会将后者改为.mm但忘记将前者修改,这样也会报类似的错误,解决办法很简单,就是将二者都改成.mm即可。
本文探讨了在C/C++编程中遇到的Specifier-Qualifier列表前预期的编译错误,并提供了具体的解决方法,包括如何正确地定义结构体。
355

被折叠的 条评论
为什么被折叠?



