Home  >  Article  >  Backend Development  >  Why use extern "C" in C++ code?

Why use extern "C" in C++ code?

WBOY
WBOYforward
2023-09-13 12:17:04706browse

为什么在C++代码中使用extern "C"?

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete