Visual C++ Compiler Error C3102

Message Text

'argument_value' : a 'positional' argument cannot follow a 'named' argument

Circumstances

As a general feature of attribute syntax, the arguments for an attribute may each be given with or without a name. When an argument is given without a name, it is given just as an argument value list or perhaps as a single argument value. Since there is no name, the given values can be interpreted only from their position in the argument list. An argument given without name is therefore called positional. It is a rule that all arguments given without a name must precede all arguments given with a name. Error C3102 is the consequence of breaking this rule.

Given an attribute statement that is otherwise correctly formed, error C3102 results from each occurrence of a positional argument immediately after a named argument. In each, the argument_value placeholder reproduces the first value from the positional argument. For example, in the fictitious

[
    rubbish (
        $%^&*,
        american = trash,
        {garbage, waste},       // C3102
        impolite = crap
    )
];

the first and third arguments are positional and the second and fourth are named. The first causes no problem, but the third is a positional argument immediately after a named argument, and triggers error C3102. The argument_value cited in the error message is “garbage”, being the first value given for the positional argument that triggers the error. Note that the error is of attribute syntax in general and is independent of whether any attribute provider recognises “rubbish” as an attribute and can answer for any interpretation of the arguments.

The product documentation shows the placeholder as attribute_name, presumably meaning to suggest that it names the attribute whose arguments are in error. If that is indeed what someone at Microsoft means to suggest, then it is demonstrably incorrect, even for the documentation’s own example.