What are name mangling and language linkage, and what does extern C guarantee or not guarantee across an ABI?
Show answer and explanation
C++ implementations commonly encode namespaces, overload signatures, and other type information into linker names, but the mangling scheme is implementation ABI rather than a portable language format. extern "C" gives a function name and function type C language linkage, normally enabling a C-callable exported name and forbidding C++ overloading of that linkage name. It does not make classes, exceptions, templates, standard-library types, object layout, or memory ownership portable across arbitrary compilers and platforms. A stable boundary should use C-compatible data, fixed ownership rules, explicit calling or export attributes where required, and keep exceptions inside the C++ side.
C++ implementations commonly encode namespaces, overload signatures, and other type information into linker names, but the mangling scheme is implementation ABI rather than a portable language format. extern "C" gives a function name and function type C language linkage, normally enabling a C-callable exported name and forbidding C++ overloading of that linkage name. It does not make classes, exceptions, templates, standard-library types, object layout, or memory ownership portable across arbitrary compilers and platforms. A stable boundary should use C-compatible data, fixed ownership rules, explicit calling or export attributes where required, and keep exceptions inside the C++ side.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.