extern c function

王林
Release: 2019-10-29 18:06:26
Original
6173 people have browsed it

extern c function

#extern The main function of "C" is to correctly implement C code to call other C language codes.

After adding extern "C", the compiler will be instructed to compile this part of the code in C language (not C). Since C supports function overloading, when the compiler compiles a function, it will also add the parameter type of the function to the compiled code, not just the function name; and the C language does not support function overloading, so compiling C The function of the language code does not include the parameter type of the function, generally only the function name is included.

This function is very useful, because before C appeared, many codes were written in C language, and very low-level libraries were also written in C language. In order to better support the original C code and the already written A good C language library needs to support C in C as much as possible, and extern "C" is one of the strategies.

This function is mainly used in the following situations:

1. C code calls C language code;

2. In the C header file Use;

3. When multiple people collaborate on development, some people may be better at C language, while others are good at C. It will also be useful in this case.

Recommended tutorial: C language tutorial

The above is the detailed content of extern c function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template