does the C standard want me to define the type before the typedef
?
It does not. The standard verbiage is as follows
6.7.2.3 Tags
7 A declaration of the form
struct-or-union identifier ;
specifies a structure or union type and declares the identifier as a
tag of that type.
8 If a type specifier of the form
struct-or-union identifier
occurs other than as part of one of the above forms, and no other
declaration of the identifier as a tag is visible, then it declares an
incomplete structure or union type, and declares the identifier as the
tag of that type.
So your original pair of declarations has well-defined behavior. The declaration for the structure is implicitly added into the translation unit at the point you define the type alias, and then completed afterward. The fact that the tool does not allow it may be due to a bug, a limitation of the tool, or perhaps an attempt to enforce a particular coding style.
There is one point in favor of the style that the tool may try to enforce, and it has to do with the C notion of scope. Specifically, function parameter list scope. As an example, see this Q&A and refer to this short example
void bar(struct foo);
struct foo {
char c;
};
void bar(struct foo f) {}
It so happens that the first declaration of bar
is declared with a type that is unique to its parameter list. The initial declaration of struct foo
is not the same type as the one used in the later function definition. As such, the code
will not compile by a conforming C compiler. Declaring the structure on its own line ahead of the first function declaration fixes this problem.