【解决方法】error C3530: “auto”不能与任何其他类型说明符组合

VS2015下,C语言

auto int cnt = 1;

会报错:error C3530: “auto”不能与任何其他类型说明符组合

这是因为:
Before Visual C++ 2010, the keyword declares a variable in the automatic storage class; that is, a variable that has a local lifetime. Starting with Visual C++ 2010, the keyword deduces the type of a variable from the declaration’s initialization expression.

VS2010以前auto是指变量的存储类型,其它三种是:静态类型变量static、寄存器类型变量register和外部类型变量extern。
VS2010后auto语义发生变化,采用了C++语法,是类型推导之意。

如果想使用VS2010之前的auto设定,具体解决方法:
https://docs.microsoft.com/en-us/cpp/build/reference/zc-auto-deduce-variable-type?view=vs-2019

简而言之:
项目属性-C/C+±其他选项 增加/Zc:auto-即可。

(VS2015测试/Zc:auto不行,必须是/Zc:auto-才可以。)

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值