What does C++ language definition say about the extent of the static keyword?
According to the C++ 17 Standard (10 Declarations)
2 A simple-declaration or nodeclspec-function-declaration of the form
attribute-specifier-seqopt decl-specifier-seqopt init-declarator-listopt ;
And (10.1 Specifiers):
1 The specifiers that can be used in a declaration are
decl-specifier:
storage-class-specifier
...
So in this declaration
static int s_One, s_Two;
the decl-specifier-seq
contains two decl-specifiers
, static
(storage class specifier) and int
. Thus the storage class specifier static
describes the both variables in the init-declarator-list
s_One
and s_Two
.
Yes, it applies to every name in that declaration:
[dcl.stc]/1:
[..] At most one storage-class-specifier shall appear in a given decl-specifier-seq [..] The storage-class-specifier applies to the name declared by each init-declarator in the list [..]