title | ms.custom | ms.date | ms.reviewer | ms.suite | ms.technology | ms.tgt_pltfrm | ms.topic | dev_langs | ms.assetid | caps.latest.revision | author | ms.author | manager | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
C Declarations and Definitions | Microsoft Docs |
11/04/2016 |
|
article |
|
575f0c9b-5554-4346-be64-b2129ca9227f |
8 |
mikeblome |
mblome |
ghogen |
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
.