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

CC++Server Side ProgrammingProgramming

You need to use extern "C" in C++ when declaring a function that was implemented/compiled in C.

Using extern "C" lets the compiler know that we want to use C naming and calling conventions. This causes the compiler to sort of entering C mode inside our C++ code. This is needed because C++ compilers mangle the names in their symbol table differently than C compilers and hence behave differently than C compilers.


raja
Published on 28-Feb-2018 08:16:49
Advertisements