Code:
#ifdef BUILD_DLL
#define MY_API __declspec(dllexport)
#else
#define MY_API __declspec(dllimport)
#endif
class MY_API A
{
public:
void some_method();
class B
{
public:
void other_method();
};
};
Do I have to add my macro (MY_API) to the B class?
If that
Bclass is also exported/imported (which, presumably, it is), then: Yes, you do.Try the following code, where we are building the DLL and exporting the classes:
Compiling this gives the following error (MSVC, Visual Studio 2019):
The message disappears, and the code compiles without issue, if we simply add the
MY_APPattribute to the nested class: