Loading...
Select Version
&pagelevel(4)&pagelevel
C functions can be used in C++ without any problems, provided each C function is declared in C++ with an extern
“C” directive and its complete prototype.
Example:
C source:
/* file = C_file.c */ int error_level; void error(int number, char *text) { printf("Error %d, Reason: %s\n", number, text); }
C++ source:
// file = C++_file.C extern "C" int error_level; extern "C" void error(int, char *); int main(void) { error_level = 100; error(error_level, "TEST"); return 0; }
The C++ source contains extern
“C
” declarations for all the C identifiers used in it.