static struct K { int x; };
Is this valid in C and C++?
static struct K { int x; };
Is this valid in C and C++?
In C, it's valid but useless.
In C++ it's invalid. You can only specify storage class for objects and functions.
Valid in C. Ill-formed in C++
In C++, specifiers extern/static can only be applied to names of objects or functions
Check out
C.1.5 Clause 7: declarations
(7.1.1) ISO C++03
No... That is not valid in C++. An alternative is (C++) : unnamed namespace
namespace
{
struct K { int x; };
}
See this related topic: