U
U
User7002020-12-01 21:04:12
C++ / C#
User700, 2020-12-01 21:04:12

Is it possible to import functions from a dll locally within a header file?

The header file declares the functions imported from the dll. Let's say lib_ff for float, lib_fd for double, etc. Is it possible to somehow limit the visibility of the first C functions. The declaration is finite in an h-file, which is not a translation unit. Is it possible to somehow undef those declarations? On the other hand, they are used from lib::f<..>.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nicholas, 2020-12-28
@romancelover

You can leave only wrappers in the header file, and declare imported functions only in the cpp file with the implementation of these wrappers.
*.h:
template<> int f(float x) ;
template<> int f(double x);
*.cpp:
extern "C" int lib_ff(float x);
extern "C" int lib_fd(double x);
template<> int f(float x) { return lib_ff(x); }
template<> int f(double x) { return lib_fd(x); }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question