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 "implicit int
" 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
fee;
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 to int
type, as in
static fee;
const fee;
register fee;
However, all this is illegal in C99 and in later versions of language, since these versions of language specification outlawed "implicit int".
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