I was writing some C code, and noticed what I thought to be an error, but was not. I had the following type declaration statement.
const fee;
However, it was uncaught initially because the compiler and I didn't catch it. So I was curious as to why C allows this and what is the default type.
Only the original version of C language standard (ANSI/ISO C89/90) allows this. Such variable declaration defaults to type
int
in accordance with "implicitint
" rule. That rule was present in C since the beginning of time. That's just how the language was originally defined.Note that the declaration-specifiers portion of a declaration cannot be omitted completely, e.g. a mere
does not declare an
int
variable. It is illegal even in the original C. But once you add some sort of declaration specifier or qualifier, the declaration becomes legal and defaults toint
type, as inHowever, all this is illegal in C99 and in later versions of language, since these versions of language specification outlawed "implicit int".