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:
Superiority of unnamed namespace over static?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With