Home >Backend Development >C++ >Why use extern 'C' in C++ code?
In C, you need to use extern "C" when declaring a function that is implemented/compiled in C.
Using extern "C" lets the compiler know that we want to use C's naming and calling conventions. This puts the compiler into a C-mode-like state inside our C code. This is necessary because the C compiler obfuscates the names differently in its symbol table and therefore behaves differently than the C compiler.
The above is the detailed content of Why use extern 'C' in C++ code?. For more information, please follow other related articles on the PHP Chinese website!