int a = 0; //it is a declaration (and definition too) statement a = 42; //it is an assignment statement
The second line is the cause of error, for it is an assignment statement.
At the namespace-level, only declaration and definition statements are allowed. Assignment-statements are not allowed at namespace level.
And by "shall be declared before its use in global scope" (from the spec's quotation) means the following:
int a = 42; int b = 2 * a; //a is being used here int c = a + b; //both a and b are being used here
If you define type instead, then:
struct A {}; //definition of A struct B { A a; }; //a is declared as member of B //(which means, A is being "used") void f(const A&, const B&); //both A and B are used in the declaration of f
struct A {}; A foo();The nameAis used in the declaration offoo().int b = a + 1;.