Browse Source

Disable the msvc warning about unexported template specializations

The warning is essentially a bug in msvc because it's harmless and requires exporting all accessible template specializations. See also http://www.unknownroad.com/rtfm/VisualStudio/warningC4251.html.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/1529/head
Dimitar Dobrev 5 years ago
parent
commit
25b9082c4c
  1. 4
      tests/CLI/CLI.h
  2. 12
      tests/CSharp/CSharp.h
  3. 16
      tests/CSharp/CSharpTemplates.h
  4. 7
      tests/Common/Common.h
  5. 5
      tests/Encodings/Encodings.h
  6. 26
      tests/StandardLib/StandardLib.h
  7. 10
      tests/Tests.h
  8. 5
      tests/VTables/VTables.h

4
tests/CLI/CLI.h

@ -68,9 +68,7 @@ public:
TestMappedTypeNonConstRefParam(const std::string); TestMappedTypeNonConstRefParam(const std::string);
const TestMappedTypeNonConstRefParam& operator=(const std::string); const TestMappedTypeNonConstRefParam& operator=(const std::string);
DISABLE_WARNING_ONCE(4251, std::string m_str;
std::string m_str;
)
}; };
class DLL_API TestMappedTypeNonConstRefParamConsumer class DLL_API TestMappedTypeNonConstRefParamConsumer

12
tests/CSharp/CSharp.h

@ -60,10 +60,7 @@ public:
protected: protected:
int P; int P;
TemplateInAnotherUnit<int> templateInAnotherUnit; TemplateInAnotherUnit<int> templateInAnotherUnit;
std::string _name;
DISABLE_WARNING_ONCE(4251,
std::string _name;
)
}; };
class DLL_API Quux class DLL_API Quux
@ -1124,16 +1121,13 @@ public:
static const char Chr; static const char Chr;
static const unsigned char UChr; static const unsigned char UChr;
static const int Int; static const int Int;
static const float Float; static const float Float;
static const std::string String;
static const char ChrArray[2]; static const char ChrArray[2];
static const int IntArray[2]; static const int IntArray[2];
static const float FloatArray[2]; static const float FloatArray[2];
static const bool BoolArray[2]; static const bool BoolArray[2];
static const void* VoidPtrArray[2]; static const void* VoidPtrArray[2];
DISABLE_WARNING_ONCE(4251,
static const std::string String;
)
}; };
static constexpr double ConstexprCreateDoubleValue(double value) { static constexpr double ConstexprCreateDoubleValue(double value) {

16
tests/CSharp/CSharpTemplates.h

@ -33,7 +33,7 @@ class DLL_API Ignored
}; };
template <typename T> template <typename T>
class DLL_API IndependentFields : public T1 class IndependentFields : public T1
{ {
typedef T Type; typedef T Type;
public: public:
@ -45,7 +45,7 @@ public:
IndependentFields(float f); IndependentFields(float f);
~IndependentFields(); ~IndependentFields();
explicit IndependentFields(const std::map<T, T> &other); explicit IndependentFields(const std::map<T, T> &other);
int getIndependent(); float getIndependent();
T getDependent(const T& t); T getDependent(const T& t);
Type property(); Type property();
static T staticDependent(const T& t); static T staticDependent(const T& t);
@ -120,9 +120,9 @@ T IndependentFields<T>::staticDependent(const T& t)
} }
template <typename T> template <typename T>
int IndependentFields<T>::getIndependent() float IndependentFields<T>::getIndependent()
{ {
return static_cast<int>(independent); return independent;
} }
template <typename X> template <typename X>
@ -143,7 +143,7 @@ class Base
}; };
template <typename T> template <typename T>
class DLL_API DependentValueFields : public Base<T> class DependentValueFields : public Base<T>
{ {
public: public:
class Nested; class Nested;
@ -248,7 +248,7 @@ public:
}; };
template <typename T> template <typename T>
class DLL_API DependentPointerFields class DependentPointerFields
{ {
public: public:
DependentPointerFields(T t = 0); DependentPointerFields(T t = 0);
@ -318,7 +318,7 @@ void TwoTemplateArgs<K, V>::takeDependentPtrToSecondTemplateArg(const V& v)
} }
template <typename T, typename D = IndependentFields<T>> template <typename T, typename D = IndependentFields<T>>
class DLL_API HasDefaultTemplateArgument class HasDefaultTemplateArgument
{ {
public: public:
HasDefaultTemplateArgument(); HasDefaultTemplateArgument();
@ -688,7 +688,7 @@ enum class UsedInTemplatedIndexer
}; };
template <typename T> template <typename T>
class DLL_API QFlags class QFlags
{ {
typedef int Int; typedef int Int;
typedef int (*Zero); typedef int (*Zero);

7
tests/Common/Common.h

@ -808,12 +808,9 @@ public:
HasStdString(); HasStdString();
~HasStdString(); ~HasStdString();
std::string testStdString(const std::string& s); std::string testStdString(const std::string& s);
std::string testStdStringPassedByValue(std::string s); std::string testStdStringPassedByValue(std::string s);
std::string s;
std::string& getStdString(); std::string& getStdString();
DISABLE_WARNING_ONCE(4251,
std::string s;
)
}; };
class DLL_API InternalCtorAmbiguity class DLL_API InternalCtorAmbiguity

5
tests/Encodings/Encodings.h

@ -4,14 +4,11 @@
class DLL_API Foo class DLL_API Foo
{ {
public: public:
DISABLE_WARNING_ONCE(4251,
static std::string StringVariable;
)
Foo(); Foo();
~Foo(); ~Foo();
const char* Unicode; const char* Unicode;
static std::string StringVariable;
// TODO: VC++ does not support char16 // TODO: VC++ does not support char16
// char16 chr16; // char16 chr16;

26
tests/StandardLib/StandardLib.h

@ -20,20 +20,18 @@ struct DLL_API TestVectors
std::vector<int> GetIntVector(); std::vector<int> GetIntVector();
int SumIntVector(std::vector<int>& vec); int SumIntVector(std::vector<int>& vec);
DISABLE_WARNING_ONCE(4251, // Should get mapped to List<int>
// Should get mapped to List<int> std::vector<int> IntVector;
std::vector<int> IntVector; // Should get mapped to List<IntPtr>
// Should get mapped to List<IntPtr> std::vector<int*> IntPtrVector;
std::vector<int*> IntPtrVector; // Should get mapped to List<IntWrapper>
// Should get mapped to List<IntWrapper> std::vector<IntWrapper> IntWrapperVector;
std::vector<IntWrapper> IntWrapperVector; // Should get mapped to List<IntWrapper>
// Should get mapped to List<IntWrapper> std::vector<IntWrapper*> IntWrapperPtrVector;
std::vector<IntWrapper*> IntWrapperPtrVector; // Should get mapped to List<IntWrapperValueType>
// Should get mapped to List<IntWrapperValueType> std::vector<IntWrapperValueType> IntWrapperValueTypeVector;
std::vector<IntWrapperValueType> IntWrapperValueTypeVector; // Should get mapped to List<IntWrapperValueType>
// Should get mapped to List<IntWrapperValueType> VectorTypedef IntWrapperValueTypeVectorTypedef;
VectorTypedef IntWrapperValueTypeVectorTypedef;
)
}; };
struct DLL_API OStreamTest struct DLL_API OStreamTest

10
tests/Tests.h

@ -20,11 +20,9 @@
#define THISCALL __thiscall #define THISCALL __thiscall
#endif #endif
#define DISABLE_WARNING_ONCE(id, block) \ // HACK: work around https://developercommunity.visualstudio.com/content/problem/1269158/c4251-shown-for-any-not-explicitly-exported-templa.html
__pragma(warning(push)) \ // harmless and requires exporting all template specializations
__pragma(warning(disable: id)) \ #pragma warning (disable : 4251 )
block \
__pragma(warning(pop))
#else #else
#define DLL_API __attribute__ ((visibility ("default"))) #define DLL_API __attribute__ ((visibility ("default")))
@ -46,8 +44,6 @@ __pragma(warning(pop))
#define THISCALL #define THISCALL
#endif #endif
#define DISABLE_WARNING_ONCE(id, block) block
#endif #endif
#define CS_OUT #define CS_OUT

5
tests/VTables/VTables.h

@ -17,10 +17,7 @@ public:
virtual int append(); virtual int append();
virtual int append(int a); virtual int append(int a);
int callVirtualWithParameter(int a); int callVirtualWithParameter(int a);
std::string s;
DISABLE_WARNING_ONCE(4251,
std::string s;
)
}; };
DLL_API int FooCallFoo(Foo* foo); DLL_API int FooCallFoo(Foo* foo);

Loading…
Cancel
Save