Answer the question
In order to leave comments, you need to log in
Why is it possible to declare a global variable of a struct type before declaring that struct type?
struct interval b;
struct interval
{
int first;
int second;
};
int main ()
{
}
int main ()
{
struct interval b; error: storage size of 'b' isn't known
struct interval
{
int first;
int second;
};
}
Answer the question
In order to leave comments, you need to log in
Why is it possible to declare a global variable
struct interval b
int main ()
{
extern struct interval b;
struct interval
{
int first;
int second;
};
}
struct interval b;
A declaration of an identifier for an object that has file scope without an initializer,
and without a storage-class specifier or with the storage-class specifier static, constitutes
a tentative definition. If a translation unit contains one or more tentative definitions for
an identifier, and the translation unit contains no external definition for that identifier,
then the behavior is exactly as if the translation unit contains a file scope declaration of
that identifier, with the composite type as of the end of the translation unit, with an
initializer equal to 0.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question