A
A
Anton2017-08-31 07:28:43
Programming
Anton, 2017-08-31 07:28:43

How to remove function decoration?

There is a library with a function that returns a container. Something like this:
std::set<std::string> function();
The library needs to be loaded dynamically, so to find this function you need to remove the decoration, how to do it?
extern "C"cannot be used because the function returns a C++ class. Under Windows, it seems possible to use a def file, but how to do this under Linux?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
tzlom, 2017-09-07
@Riki-tiki-tavi

If the pod is dynamically loaded, meaning linking with .so , then it works (I write just in case, you never know).
It seems to me not the best idea to remove the decoration in the library itself, but there is another way.
You need to declare a C function in the library that will return the C++ function pointers you need.
This is a completely adequate way, for example Qt uses a similar approach, only the function constructs an object inherited from QPlugin

V
Vasily Melnikov, 2017-09-07
@BacCM

I'm not sure it's a good idea to return stuff like this from a library. Because the implementation of containers is not fixed. Therefore, it is better to get by with simpler types, or more complex types of self-written or COM enumerator interfaces.
If the library is statically linked and one compiler is assumed, then decoration should be forgotten.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question