1

I am making my .dll library implemented in OOP manner

my macros are:

#ifndef _SWC_
#define DLLINTERFACE  __declspec(dllexport)
#else
#define DLLINTERFACE __declspec(dllimport)

after I put DLLINTERFACE before a class name using some stds on it, compiler gives me several warnings that I should provide a dll-interface for each function that I use with stds. I try to solve this by putting DLLINTERFACE on some function but gives me an error now because I already put it on the class name. Perhaps, I can remove the warning by defining all of my public functions with DLLINTERFACE with it. But how can I eliminate the warnings by defining only the class name, not the individual functions?

like this:

class DLLINTERFACE Foo
{
 public:
    std::string bar();
};

but not this:

class Foo
{
 public:
    std::string DLLINTERFACE bar();
};
ildjarn
  • 62,044
  • 9
  • 127
  • 211
mr5
  • 548
  • 1
  • 5
  • 14
  • 1
    Pretty unclear. This kind of warning is displayed when a dllexported class has members that are not exported as well. It is just a warning. An exported function returning std::string is very risky, it will malfunction when client code doesn't use the **exact** same version of the CRT or does not share the same CRT. Compiling with /MD is crucial. – Hans Passant Mar 15 '13 at 16:22
  • Lack of googling makes me post this comment. Yeah, and they suggest that it is safer to use a .lib than .dll when using `stl`s. – mr5 Mar 15 '13 at 16:36
  • 2
    short answer is : template class DLLINTERFACE std::string; before class definition.long answer is long :) try to avoid stl export and keep dll interface as much as possible close to C (not c++) i.e. use const char* not std::string. – user928204 Mar 16 '13 at 06:13

0 Answers0