Export an entire class in a dll or just its methods to avoid C4251 warning

35 Views Asked by At

When I export a class that contains an STL object, a unique_ptr, my compiler generates the C4251 warning, telling me that I have to fully specify the unique_ptr.

class IMPORT_EXPORT_API Factory
{
    std::unique_ptr<ClassA> impl{ nullptr };

public:
    std::unique_ptr<ClassB> create();

}

However, when I export just a method that also returns an STL object, but not the entire class, I don't get the error.

class Factory
{
    std::unique_ptr<ClassA> impl{ nullptr };

public:
    IMPORT_EXPORT_API std::unique_ptr<ClassB> create();

}

Why is this so?

0

There are 0 best solutions below