|
|
coherent
extern C Keyword extern
Declare storage class
extern indicates that a C element belongs to the _e_x_t_e_r_n_a_l storage
class. Both variables and functions may be declared to be ex-
tern. Use of this keyword tells the C compiler that the variable
or function is defined outside of the present file of source
code. All functions and variables defined outside of functions
are implicitly extern unless declared static.
When a source file references data that are defined in another
file, it must declare the data to be extern, or the linker will
return an error message of the form:
undefined symbol _n_a_m_e
For example, the following declares the array tzname:
extern char tzname[2][32];
When a function calls a function that is defined in another
source file or in a library, it should declare the function to be
extern. In the absence of a declaration, extern functions are
assumed to return ints, which may cause serious problems if the
function actually returns a 32-bit pointer (such as on the 68000
or i8086 LARGE model), a long, or a double.
For example, the function mmaalllloocc appears in a library and returns
a pointer; therefore, it should be declared as follows:
extern char *malloc();
If you do not do so, the compiler assumes that mmaalllloocc returns an
iinntt, and generate the error message
integer pointer pun
when you attempt to use mmaalllloocc in your program.
***** See Also *****
auto, C keywords, pun, register, static, storage class
COHERENT Lexicon Page 1
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.