Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

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

Why do we use extern "C" in C++ code? can anyone explain this


1 Answer
Priya Pallavi

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.

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.