.TH extern "" "" "C Keyword"
.PC "Declare storage class"
.PP
.B extern
indicates that a C element belongs to the \fIexternal\fR
storage class.
Both variables and functions may be declared to be
.BR extern .
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
.B extern
unless declared
.BR static .
.PP
When a source file references data that are defined in another file,
it must declare the data to be
.BR extern ,
or the linker will return an error message of the form:
.DM
	undefined symbol \fIname\fP
.DE
.PP
For example, the following declares the array
.BR tzname :
.DM
	extern char tzname[2][32];
.DE
.PP
When a function calls a function that is defined in another source
file or in a library, it should declare the function to be
.BR extern .
In the absence of a declaration,
.B extern
functions are assumed to return
.BR int s,
which may cause serious problems if the function actually
returns a 32-bit pointer (such as on the 68000 or i8086 LARGE model),
a
.BR long ,
or a
.BR double .
.PP
For example, the function \fBmalloc\fR appears in a library and
returns a pointer; therefore, it should be declared as follows:
.DM
	extern char *malloc();
.DE
.PP
If you do not do so, the compiler assumes that \fBmalloc\fR returns
an \fBint\fR, and generate the error message
.DM
	integer pointer pun
.DE
.PP
when you attempt to use \fBmalloc\fR in your program.
.SH "See Also"
.Xr "auto," auto
.Xr "C keywords," c_keyword
.Xr "pun," pun
.Xr "register," register
.Xr "static," static
.Xr "storage class" storage_c
.br
\*(AS, \(sc6.5.1
