Posted on 2019-02-21 14:51
Prayer 閱讀(1177)
評論(0) 編輯 收藏 引用 所屬分類:
LINUX/UNIX/AIX 、
makefile
轉載于:http://www.cnblogs.com/lu-yang/archive/2011/11/24/2261282.html
在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-listhttp://stackoverflow.com/questions/3888569/expected-specifier-qualifier-list-before在實際實驗過程中會發現還會有一種方法可以解決此問題:假如有一個ParserDemo工程,而其中有ParserDemoAppDelegate.h/ParserDemoAppDelegate.m和ParserDemoViewController.h/ParserDemoViewController.m. 有時候為了使用C++代碼,經常會將后者改為.mm但忘記將前者修改,這樣也會報類似的錯誤,解決辦法很簡單,就是將二者都改成.mm即可。