0

I'm beginer writting dll library. I've read about ABI compatibility. But I'm not sure It is right that pure abstract class could have stl return type or stl params.

in dll

foo.h

class IFoo {
  void Hello(const std::string&); // this declaration could be possible?
}

void export Inject(IFoo& foo);

foo.cc

IFoo* g_foo;

void Inject(IFoo& foo) {
  g_foo = &foo;
}

*g_foo It could be problem?

in application

class Foo : public IFoo {
 // implemented
}

Foo foo;
Inject(foo);
273K
  • 29,503
  • 10
  • 41
  • 64
imja
  • 1
  • It can have STL return type and params. – kiner_shah Mar 06 '23 at 06:44
  • @kiner_shah application could pass derived class to dll-side and dll-side could use it? – imja Mar 06 '23 at 06:49
  • Write the code, run it and see for yourself. – kiner_shah Mar 06 '23 at 06:50
  • Passing standard library (not STL, that's [something else](https://en.wikipedia.org/wiki/Standard_Template_Library)) objects, or references or pointers to such objects, is depending on the [**ABI**](https://en.wikipedia.org/wiki/Application_binary_interface). If the DLL and the application is built with the same ABI then it should work fine. – Some programmer dude Mar 06 '23 at 07:07
  • What exactly are you trying to achieve? See you using visual studio or gcc or do you want to be compatible with both? If visual studio are you using a single version or a mix of versions? – Alan Birtles Mar 06 '23 at 07:14
  • @AlanBirtles I have to support msvc and gcc. in windows, I build library with clang-cl and apllication uses cl import dll library – imja Mar 06 '23 at 07:19
  • 1
    Then no, you can't use standard library types in your interfaces – Alan Birtles Mar 06 '23 at 07:29

0 Answers0