C Declarations and Definitions
A "declaration" establishes an association between a particular variable, function, or type and its attributes. Overview of Declarations gives the ANSI syntax for the declaration
nonterminal. A declaration also specifies where and when an identifier can be accessed (the "linkage" of an identifier). See Lifetime, Scope, Visibility, and Linkage for information about linkage.
A "definition" of a variable establishes the same associations as a declaration but also causes storage to be allocated for the variable.
For example, the main
, find
, and count
functions and the var
and val
variables are defined in one source file, in this order:
int main() {}
int var = 0;
double val[MAXVAL];
char find( fileptr ) {}
int count( double f ) {}
The variables var
and val
can be used in the find
and count
functions; no further declarations are needed. But these names are not visible (cannot be accessed) in main
.
See also
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for