小编Tom*_*ava的帖子

[[maybe_unused]]和构造函数

尝试使用gcc 8.2.1和clang 6.0.1编译sqlpp17代码库是一种非常奇怪的体验.代码将编译器推向极限,同时我可能会遇到一些编译器错误.

从GCC Docs开始,[[maybe_unused]]从版本7开始实现,但如果以这种方式使用:

struct foo {
    foo([[maybe_unused]] bool thing1)
    {
    }
};
Run Code Online (Sandbox Code Playgroud)

我遇到了这个特定的错误:

<source>:2:9: error: expected unqualified-id before '[' token
     foo([[maybe_unused]] bool thing1)
         ^
<source>:2:9: error: expected ')' before '[' token
     foo([[maybe_unused]] bool thing1)
        ~^
         )
Compiler returned: 1
Run Code Online (Sandbox Code Playgroud)

现在,我对C++ 17知之甚少,知道这个错误是否正确,我知道clang 6编译该部分很好(并且在其他地方失败).

那么,谁是对的,铿锵的还是gcc?(对于clang和gcc,标志是-std = gnu ++ 17,由CMake生成)

c++ c++17

9
推荐指数
1
解决办法
226
查看次数

标签 统计

c++ ×1

c++17 ×1