InterviewSolution
| 1. |
When Linking C Or Assembly Language Modules With C++ Modules I Get Undefined Symbol Errors At Link Time. It Appears That None Of The C Or Assembly Public Symbols Can Be Found.? |
|
Answer» C++ is a strongly typed language. In order to support the language to its fullest, Turbo C++ MUST attach INFORMATION to the symbols generated for function names and variables. When this is done, the symbol will no longer match the standard C style function name. In order to link CORRECTLY, the compiler must be notified that the symbol is declared in an external module without TYPE information tacked on to the symbol. This is done by PROTOTYPING the function as type extern "C". Here is a quick example: extern "C" int normal_c_func( float, int, char ); // name not altered void cplusplus_function( int ); // name altered . C++ is a strongly typed language. In order to support the language to its fullest, Turbo C++ must attach information to the symbols generated for function names and variables. When this is done, the symbol will no longer match the standard C style function name. In order to link correctly, the compiler must be notified that the symbol is declared in an external module without type information tacked on to the symbol. This is done by prototyping the function as type extern "C". Here is a quick example: extern "C" int normal_c_func( float, int, char ); // name not altered void cplusplus_function( int ); // name altered . |
|