Why do I get C4251 with a non-exported member but not function argument/return?

The Microsoft compiler will emit C4251 for something like this, properly complaining that std::string isn't exported:

#include <string>

class __declspec(dllexport) Foo
{
public:
    Foo();
    int whatever();

    std::string s;  // Generates C4251
};

But the compiler doesn't complain when that same un-exported class is used as an argument or return type:

#include <string>

class __declspec(dllexport) Foo
{
public:
    Foo();
    std::string func();  // No warning emitted.
};

Can someone explain why?



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation