I am developing a shared library but the compiler came up with the warning C4351. My OS is a x64 Windows 10 1903 build 18362.267, my IDE is Visual Studio 2019, C++17.
I've tried adding a SIMPLECORE_API. But this ends with syntax error.
simplecore.h: // You can trust the class osdetection.h. It derives from Qt's library which only defines the macro OS_WIN.
#ifndef SIMPLECORE_H
#define SIMPLECORE_H
#include "osdetection.h"
#ifdef SIMPLECORE_EXPORTS
#ifdef _MSC_VER
#define SIMPLECORE_API __declspec(dllexport)
#else
#define SIMPLECORE_API
#endif // OS_LINUX
#elif defined(SIMPLELIBS_TEST)
#define SIMPLECORE_API
#endif // SIMPLECORE_EXPORTS
#endif // !SIMPLECORE_H
The error class:
#ifndef AVECTOR_H
#define AVECTOR_H
#include <list>
#include <vector>
// ... some includes
// ..
template<class T>
class AVector : public std::vector<T> { // there's the warning
public:
using std::vector<T>::vector; // makes std::vector's public functions from another class accessible, so I must not delete that
// ...
// unimportant functions
// ...
};
// function definitions
#endif // !AVECTOR_H
The class generated the following warning:
Warning C4251 'std::vector<T,std::allocator<_Ty>>::_Mypair': class 'std::_Compressed_pair<std::allocator<_Ty>,std::_Vector_val<std::_Simple_types<_Ty>>,true>' needs to have dll-interface to be used by clients of class 'std::vector<T,std::allocator<_Ty>>'
How can I fix it? I do not want to ignore it by disabling it.