I encountered this in a code review:
typedef struct C { int i; };
It compiles.
Apart from it being C-style, where structs are in a separate 'namespace', and need to be typedeffed in order to use later on, I found it weird that there is nothing defined with this typedef...
So: doesn't typedef require a type argument and an alias argument?
A quick glance over n3225 doesn't show any requirement that a name is required to be present. The text that comes the most near just says
In a simple-declaration, the optional init-declarator-list can be omitted only when declaring a class (clause 9) or enumeration (7.2), that is, when the decl-specifier-seq contains either a class-specifier, an elaborated- type-specifier with a class-key (9.1), or an enum-specifier.
So your code seems to be valid, but I think it smells bad.
Yes, typedef requires another argument. That typedef won't do anything.
Anyway it's not an error, just a deprecate usage of typedef.
C standard (n1256 in 6.7.7) talks about typedef. It doesn't say this usage is deprecated, but compilers report it is, since such statement has no effect.
Thank you for testing your code with Comeau C/C++!
Tell others about http://www.comeaucomputing.com/tryitout !
Your Comeau C/C++ test results are as follows:
Comeau C/C++ 4.3.10.1 (Oct 6 2008 11:28:09) for ONLINE_EVALUATION_BETA2
Copyright 1988-2008 Comeau Computing. All rights reserved.
MODE:strict errors C++ C++0x_extensions
"ComeauTest.c", line 1: warning: declaration requires a typedef name
typedef struct C { int i; };
^
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