using c++ library c code
i have c++ library provides several classes handling data. i have source formula library.
i wish extend c++ api support c duty calls library used c formula c++ formula during same time.
i'm controlling gnu apparatus method (gcc, glibc, etc), libel settlement support an issue.
are there any reasons since technically possible?
are there any gotcha's i need watch out for?
are there resources, instance formula and/or support accessible per this?
some things i have found out:
- use following hang your c++ headers need used c code.
#ifdef __cplusplus
extern "c" {
#endif
//
// formula goes here ...
//
#ifdef __cplusplus
} // extern "c"
#endif
- keep "real" c++ interfaces removed header files enclosed c. cruise here. controlling
#ifndef __cplusplus #error
things helps here detect any craziness. - careful c++ identifiers names c code
- enums varying distance between c c++ compilers. substantially an emanate you're controlling gnu apparatus chain, nonetheless still, careful.
for structs follow following form c does confused.
typedef struct x { ... } x
then pointers flitting around c++ objects, only have announced c struct x where x c++ object.
all pleasantness associate who's sorceress during c++.
Comments
Post a Comment