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: @@ -68,9 +68,7 @@ public:
TestMappedTypeNonConstRefParam(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

12
tests/CSharp/CSharp.h

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

16
tests/CSharp/CSharpTemplates.h

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

7
tests/Common/Common.h

@ -808,12 +808,9 @@ public: @@ -808,12 +808,9 @@ public:
HasStdString();
~HasStdString();
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();
DISABLE_WARNING_ONCE(4251,
std::string s;
)
};
class DLL_API InternalCtorAmbiguity

5
tests/Encodings/Encodings.h

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

26
tests/StandardLib/StandardLib.h

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

10
tests/Tests.h

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

5
tests/VTables/VTables.h

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

Loading…
Cancel
Save