EXTERN "C"

xiaoxiao2021-03-06  24

The role of Extern "C" {} is to indicate that the function described within the {} range is C, or you need to compile according to the C standard. It can describe its role from the declaration call: 1. Declare the following C code: EXTERN "C" {void test ()} void test () {// do test} means that you want the compiler to compile TEST function. EXTERN "C" is not supported in the C language. 2.C code calls C code EXTERN "C" {void test () // Test () is a C code or a code compiled by c standard} int main () {test ();} Regardless of the TEST function is C Written or C , as long as it is compiled by C standard, you need to add Extern "C" declaration 3. C call C code c To call C code, in C code must be declared in Extern "C" to declare function As shown above. The following is C code void test (); int main () {test ();}

So the custom function library is best coupled with Extern "C" {}, whether it is C or c, you can call the function library, if there is no this statement, and the library is C written, then the C statement is difficult to call The function library is.

转载请注明原文地址:https://www.9cbs.com/read-39416.html

New Post(0)