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:




  1. use following hang your c++ headers need used c code.





#ifdef __cplusplus
extern "c" {
#endif
//
// formula goes here ...
//
#ifdef __cplusplus
} // extern "c"
#endif



  1. keep "real" c++ interfaces removed header files enclosed c. cruise here. controlling #ifndef __cplusplus #error things helps here detect any craziness.

  2. careful c++ identifiers names c code

  3. enums varying distance between c c++ compilers. substantially an emanate you're controlling gnu apparatus chain, nonetheless still, careful.

  4. for structs follow following form c does confused.



    typedef struct x { ... } x

  5. 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

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members