When to use extern “C” in simple words? [duplicate]

You need to use extern “C” in C++ when declaring a function that was implemented/compiled in C. The use of extern “C” tells the compiler/linker to use the C naming and calling conventions, instead of the C++ name mangling and C++ calling conventions that would be used otherwise. For functions provided by other libraries, you will almost never need … Read more

What is the effect of extern “C” in C++?

extern “C” makes a function-name in C++ have C linkage (compiler does not mangle the name) so that client C code can link to (use) your function using a C compatible header file that contains just the declaration of your function. Your function definition is contained in a binary format (that was compiled by your … Read more