#include "stdafx.h" 1.Extern often has such a role in variable declarations, you declare a global variable in * .c file, this global variable is to be referenced, put it in * .h It is also declared in Extern. 2. If the function's declaration is with keyword extern, it is only implicit that this function may be defined in other source files, without other functions. That is, the following two functions declarations are different:
EXTERN INT F (); and INT F ();
================================= 如果 If the defined function is declared in the corresponding header file The function, then use these functions in other C / CPP files, just include this header file.
If you don't want to include the header file, declare the function in the C / CPP. In general, the declaration defines the function of this document without "extern", declares that the function defined in other files is "extern", so that the function that is called other files defined in this document does not include the header file.
Include "* .h" to declare the function, and use it directly after the declaration. ==========================================================================================================================================================
for example:
The //Extern.cpp content is as follows:
// extern.cpp: defines the entry point for the console application.//
#include "stdafx.h"
EXTERN Print (char * p);
INT Main (int Argc, char * argv []) {char * p = "Hello World!"; Print (P); Return 0;}
//print.cpp content is as follows
#include "stdafx.h" #include "stdio.h" print (char * s) {printf ("the string IS% S / N", S);}
The result will operate normally and output results. If "extern" is removed, the program can still run normally.
This shows that "extern" can be available in the function declaration, just to mark the function in this document, or in other files. As long as your function is declared before use, you can use the header file.