Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Part of the issue with doing that is that by compiling as C++ the symbols get mangled in a different manner and can lead to areas where you have to compile nearly everything as C++. Or you have to make sure that everything that you might want to face the outside world is marked with extern "C" {}.


This is by and large a very minor point. I typically define a macro similar to this:

  #ifdef __cplusplus
  #define CFUN extern "C"
  #else
  #define CFUN
  #endif
and mark any C-callable functions with it. Easy. The real linkage problems you'll run into with C++ are in dynamic libraries. The higher level of abstraction hides some problems that are really obvious at the C level. Fortunately, you only need to care about this if you need to support third-party plugins to your software. If that's the case, you may want to reconsider your choice of using a low-level language such as C++ or C.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: