According to (c) ANSI ISO/IEC 14882:2003, page 127:
Linkage specifications nest. When linkage specifications nest, the innermost one determines the langu
As an API specifies the the external interface of the source code of a program, an ABI specifies the external interface of the binary code of the program (the compiled version).
Originally, C functions simply had a few different forms. Something like
int foo(int);
would be prefixed by an underscore by the compiler, to form _foo
, and then exported to be made available to other applications.
However, that wasn't enough. If you look at the Windows API, for instance, you will see things like:
DWORD CreateWindowW(...); //Original parameters
DWORD CreateWindowExW(..., ...); //More parameters
This is because there's no way to distinguish between the overloads of a function simply by looking at the name of the function, so people started changing them by adding an Ex
suffix (or the like).
This grew to be pretty ugly, and it still didn't allow for operator overloading, which was featured in C++. Because of this, C++ came up with name mangling, to put extra information in the name of the function, like the data types of its parameters, and making it something cryptic with lots of @
symbols.
It was all well, except that it wasn't completely standardized.
Of course, as new languages and compilers came about, each came up with its own scheme, some incompatible with others. So if you need to import or export an external function, you need to specify what kind of ABI the compiler should look for, hence the extern "C++"
you have there.