views:

126

answers:

3

Are there any high level language that don't support using C++ libraries?

+1  A: 

This is a bit of an anti-answer, but many popular high-level languages can have bindings to C++ library code created for them via swig (http://swig.org/).

Mr Fooz
Didn't know about this at all; thanks for sharing.
Steven Sudit
+2  A: 

I can't think of any language that is able to use C++ libraries directly. Even getting C++ to do it can be tricky (if the library was compiled with a different compiler than you're using)

Of course, if you write a wrapper of some kind (either a wrapper for the specific library, or some kind of bindings library that lets you expose specific types), then any language can use C++ libraries. But directly, as-is, with no extra work? I don't think any language other than C++ can do it.

jalf
+7  A: 

Using C++ libraries from other high-level languages has a couple of major obstacles:

  • if the library is OO, you need to be able to create a C++ object in the calling language - this is not easy.

  • C++ implementations use a technique known as "name-mangling" to ensure type-safe linkage. Unfortunately, there is no standard for name mangling, so C++ code cannot even easily be called between different C++ implementations.

So the answer to your question is that most HLLs will have problems calling C++ code. They may also have problems calling any other language of course - there are actually no standardised binary interfaces between languages, except ad hoc, platform-specifc ones.

anon