For a shared library project written in C, if I rewrite part of the code in C++, but exactly the same APIs is kept, will I have any ABI compatibility issues?
Asked
Active
Viewed 54 times
1 Answers
4
If you keep the same API (function names and parameter types) you should be good to go.
What you will need to do is wrap your header files with this (copy & pasted from here):
#ifdef __cplusplus
extern "C" {
#endif
// all of your legacy C code here
#ifdef __cplusplus
}
#endif
This makes sure that the C++ compiler doesn't mangle those names, so the C compiler's extern symbols can still be linked against the exports.

Community
- 1
- 1

Jonathon Reinhart
- 132,704
- 33
- 254
- 328