It is not uncommon for C++ code fragments to be called by non-C++ programs such as a C-based communication software, COBOL based TP monitors and the likes. However, global functions in C++ cannot be called by non-C++ programs since the function name is very different from the one supplied by the programmer. Why is this? By default, the C++ compiler uses a technique termed name mangling which incorporates the function name with its signature (list of arguments) in order to create a unique name for it, even in case of overloading (this technique is used both for external function and class member functions).
//the following global functions have distinct names generated by the compiler
void f(int); //x__f_i this may be the name generated by the compiler for this f()
void f(long, char* ); //x__f_pc this may be the name generated by the compiler for this f()
It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com. Already a member?
To become a member of DevX.com create your Member Profile by completing the form below. Membership is free!
If you have a hot tip and we publish it, we'll pay you. However, due to accounting overhead we no longer pay $10 for a single tip submission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what the technique does and why it's useful. If it includes code, limit it to 20 lines if possible. Submit your tip here.