Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Beginner
Oct 29, 1998

C/C++ Linking

Question:
If I make a C++ library and supply it to a client who does not have a C++ compiler, can they call my C++ functions from their C routines? That is, is it possible to use the C++ library without having a C++ compiler installed (on UNIIX).

Answer:
It is possible to use your library as long as your client uses a language that allows them to call the library. For example, this is possible from C but they will need at least a C compiler.

There are some more complicated issues, however. Because C++ allows you to create functions with the same name as long as the arguments are different (function overloading), C++ "mangles" the function name based on the arguments so the linker can tell the difference. Therefore, in order to call C++ routines from C, you must either know the mangled names and call them, or you must export your C++ functions as C functions.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date