C Programming External Functions

Last modified by Microchip on 2023/11/09 09:06

Functions by Default Have Global Scope Within a Project

A function defined within any file in a project may be called from any other file.

extern Keyword is Not Required, But Function Prototype is Required in Calling File or #included Header File

The only thing required to access the externally defined function is a function prototype in the calling file or a #included header file. The use of header files for this purpose is extremely common. The functions available in the standard C library all have associated header files that may be included in your source files. These header files contain the function prototypes for the library functions, which let the compiler know how to handle these function calls even though the definition of the function is somewhere else.

Information

Note: It is perfectly valid to use the extern keyword in front of a function definition, but it isn't strictly required.

External Function .c sample code