Attribute Blocks

An attribute block consists of a left square bracket, one or more attribute statements separated by commas, an optional trailing comma, and finally a right square bracket. Thus,


[ attribute-statement-list [,] ]



attribute-statement-list , attribute-statement

It is an error (C3409) if the attribute block is empty, meaning specifically that the token immediately after the opening square bracket is a closing square bracket. For example,

];      // C3409

It is an error (C2143) for an attribute statement, as interpreted by deeper processing of the syntax, to be followed by anything other than a comma (to permit continuation to another attribute statement) or a right square bracket (to close the attribute block). The error message in this case complains of missing a right square bracket before the offending token. For example,

    uuid {00000000-0000-0000-0000-000000000000} + rubbish
]                                                               // C2143
class Test;

is interpreted as containing one attribute statement, up to and including the closing curly bracket. The excess causes the error message

TEST.CPP(3) : error C2143: syntax error : missing ']' before '+ rubbish'

with “+ rubbish” reproduced, though assigned to the wrong line number. The offending token is not necessarily reproduced, but may instead be described only by type. If the plus sign is removed from the preceding example, the excess is tokenised as an identifier, and

    uuid {00000000-0000-0000-0000-000000000000} rubbish         // C2143
class Test;

then produces the less helpful

TEST.CPP(2) : error C2143: syntax error : missing ']' before 'identifier'

though at least the line number is now correct.