Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/145.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 应用于类型别名声明的[[maybe_unused]]属性的语法_C++_Attributes_C++17 - Fatal编程技术网

C++ 应用于类型别名声明的[[maybe_unused]]属性的语法

C++ 应用于类型别名声明的[[maybe_unused]]属性的语法,c++,attributes,c++17,C++,Attributes,C++17,试图找出[[可能未使用]]属性的正确语法导致: 突然之间,它只有在目标类型名称之后写入时才起作用。这似乎很奇怪,因为它通常放在前面。这真的是一个正确的语法还是刚刚出现的编译器故障?根据以下规则,这是正确的放置语法: 可选属性说明符seq位于标识符之后,而=之前,这很不幸。同样根据链接页面typedef[[maybe_unused]]int Y也应该起作用(decl说明符seq:decl说明符属性说明符seq(opt)),但是它不应该起作用。@VTT不,它不应该起作用。再读一遍语法。 int ma

试图找出
[[可能未使用]]
属性的正确语法导致:


突然之间,它只有在目标类型名称之后写入时才起作用。这似乎很奇怪,因为它通常放在前面。这真的是一个正确的语法还是刚刚出现的编译器故障?

根据以下规则,这是正确的放置语法:


可选属性说明符seq位于标识符之后,而
=

之前,这很不幸。同样根据链接页面
typedef[[maybe_unused]]int Y也应该起作用(decl说明符seq:decl说明符属性说明符seq(opt)),但是它不应该起作用。@VTT不,它不应该起作用。再读一遍语法。
int main()
{
    typedef int X; // warning
    [[maybe_unused]] typedef int Y; // Ok
    using Z = int; // warning
    //[[maybe_unused]] using W1 = int; // error: expected ';' before 'using'
    //using [[maybe_unused]] W2 = int; // error: expected nested-name-specifier before '[' token
    using W3 [[maybe_unused]] = int; // Ok
    //using W4 = [[maybe_unused]] int; // error: an attribute list cannot appear here
}
alias-declaration:
    using identifier attribute-specifier-seq = defining-type-id ;