Calling the name of C ++ classes and its member functions?

Is there a way to avoid manipulating the names of C ++ classes and its member functions when exposing from a C ++ dll.

Can't I use the def def mechanism in this regard?

+3
source share
4 answers

I think the best way to do this is to provide C shells around the C ++ library. This was pretty popular 10 or more years ago when I was programming in C ++, but I don't know if this was done anymore.

Basically, for each class Cfor each constructor ctorthat must be open to create a method extern "C" CPtr cCtor(....)that returns an opaque pointer CPtr, and for each function functhat you need to open, you createextern "C" cFunc(CPtr,....)

- CStruct, - , .

+3

. mangling , , .

C extern "C" {}, , .. ++ C- C-.

+4

, , - extern "C". , . ( , ).

+2

A virtual function will be the answer, I think you noticed COM, create an instance, it gives you a pointer to this interface, presented as a class. I assume that the declared methods are not allowed by name, but by slot index.

0
source

Source: https://habr.com/ru/post/1703667/


All Articles