Tag: 铿锵声

constexpr和初始化一个静态const void指针reinterpret强制转换,哪个编译器是正确的?

考虑下面的一段代码: struct foo { static constexpr const void* ptr = reinterpret_cast<const void*>(0x1); }; auto main() -> int { return 0; } 上面的例子在g ++ v4.9( Live Demo )中编译得很好,但是在v3.4( Live Demo )中编译失败,并且产生下面的错误: 错误:constexprvariables'ptr'必须由一个常量expression式初始化 问题: 两个编译器哪一个按照标准是正确的? 宣称这种expression方式的正确方法是什么?

为什么这个程序被三个C ++编译器错误地拒绝?

编写一个我编写的C ++程序时遇到一些困难。 这个程序非常简单,据我所知,符合C ++标准中规定的所有规则。 我已经仔细阅读了ISO / IEC 14882:2003的全部内容。 该计划如下: 这是我在Visual C ++ 2010编译这个程序时收到的输出: c:\dev>cl /nologo helloworld.png cl : Command line warning D9024 : unrecognized source file type 'helloworld.png', object file assumed helloworld.png : fatal error LNK1107: invalid or corrupt file: cannot read at 0x5172 很沮丧,我尝试了g ++ 4.5.2,但同样没有帮助: c:\dev>g++ helloworld.png helloworld.png: file not recognized: File format […]