相关疑难解决方法(0)

为什么这个无效的代码在g ++ 6.0上成功编译?

考虑这个奇怪的程序:

int main()
{
    int(*){} Is it C++14 or any other language?
}
Run Code Online (Sandbox Code Playgroud)

(在这里这里观看现场演示.)

即使//缺少注释,即使我-pedantic-errors在g ++ 6.0中使用选项,代码编译也没有任何错误和警告.这对我来说似乎是一个编译器错误.它真的是编译器中的错误吗?

c++ g++

84
推荐指数
2
解决办法
3485
查看次数

这是一种新的C++ 11评论风格吗?

虽然我试图理解为什么代码int(*)();编译好用g ++编译我发现更奇怪的事情:

int main()
{
    int(*){} Is it C++11 or any other language?
}
Run Code Online (Sandbox Code Playgroud)

这段代码用g ++ 4.8.1编译得很好,参见live example(flags :)-std=c++11 -pedantic-errors.clang 3.4vc ++ 2013都没有编译它.

它是一种新的C++ 11样式的注释,只有g ++支持吗?还是编译错误?


以下是我发现的关于这种"评论"风格的内容:

  1. 注释的通常结构(可以省略的部分括在括号中[ ... ]):

    int // or another valid C++ type
    (*) // or another sequence of '*' and/or '&' characters with nonzero length
    {"[Comment header]"}
    [Comment body]
    {[Comment footnote]}
    
    Run Code Online (Sandbox Code Playgroud)
  2. 而不是使用脚注终止符号;可以使用:int(*){} Comment …

c++ gcc comments g++ c++11

12
推荐指数
0
解决办法
249
查看次数

标签 统计

c++ ×2

g++ ×2

c++11 ×1

comments ×1

gcc ×1