I'm taking a programming languages course and we're talking about the extern "C"
declaration.
How does this declaration work at a deeper level other than "it interfaces C and C++"? How does this affect the bindings that take place in the program as well?
extern "C"
is used to ensure that the symbols following are not mangled (decorated).Example:
Let's say we have the following code in a file called
test.cpp
:If you run
gcc -c test.cpp -o test.o
Take a look at the symbols names:
foo()
keeps its name.