Question:
Calling the functions in the C source files or C libraries from C++ code
Answer:
When using C code - whether it is in C source files or C libraries - from C++ code, you have to inform the build tools that these functions are in C, so that it knows how to call them. When a C source file is compiled, the function names are given an underscore prefix in the generated assembly. For example, "void foo(int a) {...}" becomes "_foo" in the generated assembly. This is the symbol used to call the function.
As C++ supports function overloading, simply adding an underscore would not differentiate between the variances of the same function. So, a suffix is added to the symbol name in assembly when a C++ source file is compiled. For example. "void foo(void)" becomes "_foo__Fv" ("__F" = function, "v" = void), while "void foo(unsigned char *a, int b)" would become "_func__FPUci" in the assembly file, where the "__FPUci" means the Function ("__F") takes a Pointer ("P") to an Unsigned char ("Uc"), and an integer ("i") as it's parameters: "__FPUci".
This is true not only when you build the source that contains the function definition, but also when you call the function from your code. Where this causes problems, is if you call "foo(void)" from your C++ source, but the function exists in a C library or source file, the generated assembly will call "_foo_Fv", but the linker will not be able to resolve that reference, as compiling the C source file would only produce a symbol "_foo".
You can let the Compiler know how to resolve these references using the "extern" qualifier. So, if you have the function "int rocket(int)" in a C source file, or C library, simply add the prototype to your C++ source code (or a header file included by the C++ source) as follows:
extern "C" int rocket(int);
This tells the C++ Compiler that "rocket" is a C function, and will generate C-style references to this function in the generated assembly.