static struct K { int x; };
Is this valid in C and C ++?
Valid in C. Not formed in C ++
In C ++, extern / static specifiers can only be applied to object or function names
Departure
C.1.5 Clause 7: declarations (7.1.1) ISO C ++ 03
declarations
In C, it is valid but useless .
In C ++, it is invalid. You can specify a storage class for objects and functions.
No ... This is not valid in C ++. An alternative is (C ++): an unnamed namespace
namespace { struct K { int x; }; }
See this topic:
Is static namespace superior to static?
http://ideone.com/YqWd8
http://ideone.com/XtHYy