gpt4 book ai didi

c++ - typedef - 原始类型到原始类型

转载 作者:塔克拉玛干 更新时间:2023-11-03 08:11:19 26 4
gpt4 key购买 nike

C++ 将原始类型转换为另一个原始类型的类型定义是否有效?

typedef int long;

在 VS 2012 上,发出警告但编译正常。

warning C4091: 'typedef ' : ignored on left of 'long' when no variable is declared

但是在 gcc-4.3.4 上,它失败了。

error: declaration doesnot declare anything.

哪个编译器符合标准?

PS:我不会在生产代码中写这样的东西。只是想出了这个想法并进行了检查。

最佳答案

Is it valid C++

没有。 C++11,§ 7.1.3.6:

In a given scope, a typedef specifier shall not be used to redefine the name of any type declared in that scope to refer to a different type.

关于c++ - typedef - 原始类型到原始类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13649071/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com