iOS duplicate symbol 变量 in 类名 报错

该错误信息是我在一个.h文件里申明了公共变量,然后在其他类里重复使用。

Build Settings ->No Common Blocks默认为YES,编译器就报错了,需要修改Build Settings里的No Common Blocks为NO。

 

NO Common Blocks 是什么?

 官方的解释是:

    In C, allocate even uninitialized global variables in the data section of the object file, rather than generating them as common blocks. This has the effect that if the same variable is declared (without extern ) in two different compilations, you will get an error when you link them. The only reason this might be useful is if you wish to verify that the program will work on other systems which always work this way.

    在C语言中,在目标文件的数据段分配甚至未初始化的全局变量,而不是生成它们作为公共块。这样做,如果同一个变量被声明(没有extern)放在两个不同的汇编,你会当你将它们链接得到一个错误的影响。这可能是有用的唯一原因是,如果你想验证程序将在其他系统上,它总是以这种方式工作工作。

转载于:https://www.cnblogs.com/weiboyuan/p/6196345.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值