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 voidcharstruct 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即可。


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值