- C and C++ compilers process source code in three distinct stages: pre-processing, compilation proper and linking
- mixed language program require linkage convention declarations to ensure that the function identifiers used in the definition and in the function call are identical
- To resolve this incompatibility, we direct the C++ compiler to use the "C" linkage convention in calling hello() rather than the default C++ convention. We do so by wrapping the include directive in a linkage convention declaration:
extern "C" { /* identifies C linkage convention */
#include "hello.h"
}
No comments:
Post a Comment