开发者

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

开发者 https://www.devze.com 2022-12-28 04:40 出处:网络
Are the开发者_如何学Gore any high level language that don\'t support using C++ libraries?Using C++ libraries from other high-level languages has a couple of major obstacles:

Are the开发者_如何学Gore any high level language that don't support using C++ libraries?


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.


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.


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/).

0

精彩评论

暂无评论...
验证码 换一张
取 消