From the C99 standard, 6.7(5):
A declaration specifies the interpretation and attributes of a set of identifiers. A definition of an identifier is a d
For the same reason that other declarations are allowed to be declared multiple times. For example:
void foo(int a);
void foo(int a);
int main()
{
foo(42);
}
void foo(int a)
{
printf("%d\n", a);
}
This allows more than one header to declare a function or structure, and allow two or more such headers to be included in the same translation unit.
typedefs are similar to prototyping a function or structure -- they declare identifiers that have some compile time meaning, but no runtime meaning. For example, the following wouldn't compile:
int main()
{
typedef int x;
typedef int x;
x = 42;
}
because x
does not name a variable; it is only a compile time alias for the name int
.