From ef2e6079ba7c3f0b1c7678e093e9f713022bdef6 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 5 Feb 2016 13:30:26 -0600 Subject: [PATCH 01/12] Wrap WIN32 #pragma warning(disable) inside push/pop Exclude from MinGW, G++ doesn't understand these pragmas. --- src/misc/pv/epicsException.h | 9 ++++++--- src/pv/pvType.h | 12 +++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/misc/pv/epicsException.h b/src/misc/pv/epicsException.h index a25279e..3ff925a 100644 --- a/src/misc/pv/epicsException.h +++ b/src/misc/pv/epicsException.h @@ -35,8 +35,6 @@ #define EPICSEXCEPTION_H_ #ifdef _WIN32 -#pragma warning( push ) -#pragma warning(disable: 4275) // warning C4275: non dll-interface class used as base for dll-interface class (std::logic_error) #endif #include @@ -67,6 +65,11 @@ # define EXCEPT_USE_NONE #endif +#if defined(_WIN32) && !defined(_MINGW) +#pragma warning( push ) +#pragma warning(disable: 4275) // warning C4275: non dll-interface class used as base for dll-interface class (std::logic_error) +#endif + namespace epics { namespace pvData { @@ -228,7 +231,7 @@ private: mutable std::string base_msg; }; -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_MINGW) #pragma warning( pop ) #endif diff --git a/src/pv/pvType.h b/src/pv/pvType.h index 1a77ead..48bcc43 100644 --- a/src/pv/pvType.h +++ b/src/pv/pvType.h @@ -17,6 +17,10 @@ #ifdef _WIN32 #define NOMINMAX +#endif + +#if defined(_WIN32) && !defined(_MINGW) +#pragma warning( push ) #pragma warning(disable: 4251) #endif @@ -126,7 +130,9 @@ typedef std::vector::iterator StringArray_iterator; typedef std::vector::const_iterator StringArray_const_iterator; }} + +#if defined(_WIN32) && !defined(_MINGW) +#pragma warning( pop ) +#endif + #endif /* PVTYPE_H */ - - - From 5c16357fe2f79a6f825f2a748fa7003cbe834c3a Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 5 Feb 2016 13:35:15 -0600 Subject: [PATCH 02/12] Don't redefine NOMINMAX (clean up MinGW warnings) --- src/factory/FieldCreateFactory.cpp | 2 +- src/factory/PVDataCreateFactory.cpp | 2 +- src/misc/pv/epicsException.h | 3 ++- src/misc/pv/sharedVector.h | 2 +- src/misc/timer.cpp | 2 +- src/pv/pvData.h | 2 +- src/pv/pvType.h | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/factory/FieldCreateFactory.cpp b/src/factory/FieldCreateFactory.cpp index 7551315..374fdd3 100644 --- a/src/factory/FieldCreateFactory.cpp +++ b/src/factory/FieldCreateFactory.cpp @@ -8,7 +8,7 @@ * @author mrk */ -#ifdef _WIN32 +#if defined(_WIN32) && !defined(NOMINMAX) #define NOMINMAX #endif diff --git a/src/factory/PVDataCreateFactory.cpp b/src/factory/PVDataCreateFactory.cpp index a622384..0a9e4c0 100644 --- a/src/factory/PVDataCreateFactory.cpp +++ b/src/factory/PVDataCreateFactory.cpp @@ -8,7 +8,7 @@ * @author mrk */ -#ifdef _WIN32 +#if defined(_WIN32) && !defined(NOMINMAX) #define NOMINMAX #endif diff --git a/src/misc/pv/epicsException.h b/src/misc/pv/epicsException.h index 3ff925a..e60709a 100644 --- a/src/misc/pv/epicsException.h +++ b/src/misc/pv/epicsException.h @@ -34,7 +34,8 @@ #ifndef EPICSEXCEPTION_H_ #define EPICSEXCEPTION_H_ -#ifdef _WIN32 +#if defined(_WIN32) && !defined(NOMINMAX) +#define NOMINMAX #endif #include diff --git a/src/misc/pv/sharedVector.h b/src/misc/pv/sharedVector.h index b092d91..b6eccb2 100644 --- a/src/misc/pv/sharedVector.h +++ b/src/misc/pv/sharedVector.h @@ -7,7 +7,7 @@ #ifndef SHAREDVECTOR_H #define SHAREDVECTOR_H -#ifdef _WIN32 +#if defined(_WIN32) && !defined(NOMINMAX) #define NOMINMAX #endif diff --git a/src/misc/timer.cpp b/src/misc/timer.cpp index b10f22f..bdaafc1 100644 --- a/src/misc/timer.cpp +++ b/src/misc/timer.cpp @@ -8,7 +8,7 @@ * @author mrk */ -#ifdef _WIN32 +#if defined(_WIN32) && !defined(NOMINMAX) #define NOMINMAX #endif diff --git a/src/pv/pvData.h b/src/pv/pvData.h index 94e30ee..d89c1fd 100644 --- a/src/pv/pvData.h +++ b/src/pv/pvData.h @@ -10,7 +10,7 @@ #ifndef PVDATA_H #define PVDATA_H -#ifdef _WIN32 +#if defined(_WIN32) && !defined(NOMINMAX) #define NOMINMAX #endif diff --git a/src/pv/pvType.h b/src/pv/pvType.h index 48bcc43..28ad878 100644 --- a/src/pv/pvType.h +++ b/src/pv/pvType.h @@ -15,7 +15,7 @@ #ifndef PVTYPE_H #define PVTYPE_H -#ifdef _WIN32 +#if defined(_WIN32) && !defined(NOMINMAX) #define NOMINMAX #endif From c3d7fa0d26180b801d6c81f5c63492c25827dca6 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 5 Feb 2016 13:39:09 -0600 Subject: [PATCH 03/12] Declare explicit specializations Resolves duplicate symbol build error on MinGW. --- src/pv/pvData.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pv/pvData.h b/src/pv/pvData.h index d89c1fd..9cca66a 100644 --- a/src/pv/pvData.h +++ b/src/pv/pvData.h @@ -436,6 +436,16 @@ private: friend class PVDataCreate; }; +/** + * @brief Some explicit specializations exist (defined in PVScalar.cpp) + */ +template<> + std::ostream& PVScalarValue::dumpValue(std::ostream& o) const; +template<> + std::ostream& PVScalarValue::dumpValue(std::ostream& o) const; +template<> + std::ostream& PVScalarValue::dumpValue(std::ostream& o) const; + /** * typedefs for the various possible scalar types. */ From 3fadc9b481f8f17db94603e2289e64d8ce6c2ca6 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 5 Feb 2016 13:43:13 -0600 Subject: [PATCH 04/12] Remove unnecessary includes from epicsException.h Fix up byteBuffer.h and epicsException.cpp to match. --- src/misc/epicsException.cpp | 3 ++- src/misc/pv/byteBuffer.h | 7 ++++--- src/misc/pv/epicsException.h | 4 ---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/misc/epicsException.cpp b/src/misc/epicsException.cpp index 48f59b8..e29b649 100644 --- a/src/misc/epicsException.cpp +++ b/src/misc/epicsException.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #define epicsExportSharedSymbols @@ -50,7 +51,7 @@ ExceptionMixin::show() const out< -#include +#include +#include #ifdef epicsExportSharedSymbols #define byteBufferepicsExportSharedSymbols @@ -224,7 +225,7 @@ public: * Must be one of EPICS_BYTE_ORDER,EPICS_ENDIAN_LITTLE,EPICS_ENDIAN_BIG. */ ByteBuffer(std::size_t size, int byteOrder = EPICS_BYTE_ORDER) : - _buffer((char*)malloc(size)), _size(size), + _buffer((char*)std::malloc(size)), _size(size), _reverseEndianess(byteOrder != EPICS_BYTE_ORDER), _reverseFloatEndianess(byteOrder != EPICS_FLOAT_WORD_ORDER), _wrapped(false) @@ -257,7 +258,7 @@ public: */ ~ByteBuffer() { - if (_buffer && !_wrapped) free(_buffer); + if (_buffer && !_wrapped) std::free(_buffer); } /** * Set the byte order. diff --git a/src/misc/pv/epicsException.h b/src/misc/pv/epicsException.h index e60709a..55982c1 100644 --- a/src/misc/pv/epicsException.h +++ b/src/misc/pv/epicsException.h @@ -40,12 +40,8 @@ #include #include - #include -#include -#include - #include // Users may redefine this for a large size if desired From fa6c2c7683f51752c7433220b9cc655820b799ee Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 5 Feb 2016 14:13:43 -0600 Subject: [PATCH 05/12] EPICS sources use _MINGW for arch-detection --- src/misc/pv/epicsException.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/misc/pv/epicsException.h b/src/misc/pv/epicsException.h index 55982c1..a5f9734 100644 --- a/src/misc/pv/epicsException.h +++ b/src/misc/pv/epicsException.h @@ -53,7 +53,7 @@ # include # include # define EXCEPT_USE_BACKTRACE -#elif defined(_WIN32) && !defined(__MINGW__) && !defined(SKIP_DBGHELP) +#elif defined(_WIN32) && !defined(_MINGW) && !defined(SKIP_DBGHELP) # define _WINSOCKAPI_ # include # include From ed5f48b353c20a62b6da8777707082a1eabc8930 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 5 Feb 2016 14:23:59 -0600 Subject: [PATCH 06/12] EPICS sources use vxWorks for arch-detection --- src/misc/parseToPOD.cpp | 4 ++-- src/misc/pv/sharedPtr.h | 2 +- src/pv/pvData.h | 4 ++-- src/pv/pvType.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/misc/parseToPOD.cpp b/src/misc/parseToPOD.cpp index 4ac3788..add8f21 100644 --- a/src/misc/parseToPOD.cpp +++ b/src/misc/parseToPOD.cpp @@ -308,7 +308,7 @@ noconvert: return 0; } -#if defined(__vxworks) +#if defined(vxWorks) /* vxworks version of std::istringstream >>uint64_t is buggy, we use out own implementation */ static unsigned long long strtoull(const char *nptr, char **endptr, int base) @@ -551,7 +551,7 @@ void parseToPOD(const string& in, float *out) { void parseToPOD(const string& in, double *out) { int err = epicsParseDouble(in.c_str(), out, NULL); if(err) handleParseError(err); -#if defined(__vxworks) +#if defined(vxWorks) /* vxWorks strtod returns [-]epicsINF when it should return ERANGE error * if [-]epicsINF is returned and first char is a digit then translate this into ERANGE error */ diff --git a/src/misc/pv/sharedPtr.h b/src/misc/pv/sharedPtr.h index 05bd3ca..b2d1007 100644 --- a/src/misc/pv/sharedPtr.h +++ b/src/misc/pv/sharedPtr.h @@ -26,7 +26,7 @@ // where should we look? -#if defined(__GNUC__) && __GNUC__>=4 && !defined(__vxworks) +#if defined(__GNUC__) && __GNUC__>=4 && !defined(vxWorks) // GCC >=4.0.0 # define SHARED_FROM_TR1 diff --git a/src/pv/pvData.h b/src/pv/pvData.h index 9cca66a..0f2605d 100644 --- a/src/pv/pvData.h +++ b/src/pv/pvData.h @@ -29,11 +29,11 @@ #include #include -#if defined(__vxworks) && !defined(_WRS_VXWORKS_MAJOR) +#if defined(vxWorks) && !defined(_WRS_VXWORKS_MAJOR) typedef class std::ios std::ios_base; #endif -#if defined(__GNUC__) && !(defined(__vxworks) && !defined(_WRS_VXWORKS_MAJOR)) +#if defined(__GNUC__) && !(defined(vxWorks) && !defined(_WRS_VXWORKS_MAJOR)) #define USAGE_DEPRECATED __attribute__((deprecated)) #define USAGE_ERROR(MSG) __attribute__((error(MSG))) #else diff --git a/src/pv/pvType.h b/src/pv/pvType.h index 28ad878..fe2d1ab 100644 --- a/src/pv/pvType.h +++ b/src/pv/pvType.h @@ -27,7 +27,7 @@ #include #include -#if defined(__vxworks) && \ +#if defined(vxWorks) && \ (_WRS_VXWORKS_MAJOR+0 <= 6) && (_WRS_VXWORKS_MINOR+0 < 9) typedef int intptr_t; typedef unsigned int uintptr_t; From 378def0a5859f5aa39f506e25f61474850c5de18 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 5 Feb 2016 14:26:23 -0600 Subject: [PATCH 07/12] Fix logic for when to define strtoll() and strtoull() Needed for MinGW and VxWorks when built against Base-3.15 --- src/misc/parseToPOD.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/misc/parseToPOD.cpp b/src/misc/parseToPOD.cpp index add8f21..d0e3bcf 100644 --- a/src/misc/parseToPOD.cpp +++ b/src/misc/parseToPOD.cpp @@ -250,17 +250,15 @@ epicsParseFloat(const char *str, float *to, char **units) #endif // MS Visual Studio 2013 defines strtoll, etc. -#if defined(_WIN32) -# if (_MSC_VER >= 1800) -# define WIN_NEEDS_OLL_FUNC 0 -# else -# define WIN_NEEDS_OLL_FUNC 1 -# endif +#if defined(_WIN32) && !defined(_MINGW) +# define NEED_OLL_FUNCS (_MSC_VER < 1800) +#elif defined(vxWorks) +# define NEED_OLL_FUNCS !defined(_WRS_VXWORKS_MAJOR) #else -# define WIN_NEEDS_OLL_FUNC 0 +# define NEED_OLL_FUNCS 0 #endif -#if defined(NEED_LONGLONG) && (defined(__vxworks) || WIN_NEEDS_OLL_FUNC) +#if defined(NEED_LONGLONG) && NEED_OLL_FUNCS static long long strtoll(const char *ptr, char ** endp, int base) { From fd1fe53b4947bbf241fd121cb5fd313b79f1c2d2 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 5 Feb 2016 14:30:37 -0600 Subject: [PATCH 08/12] Use the EPICS_DEPRECATED macro from Base. Neither USAGE_DEPRECATED nor USAGE_ERROR are currently used in the V4 code-base. --- src/pv/pvData.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pv/pvData.h b/src/pv/pvData.h index 0f2605d..796abd6 100644 --- a/src/pv/pvData.h +++ b/src/pv/pvData.h @@ -33,11 +33,11 @@ typedef class std::ios std::ios_base; #endif +#define USAGE_DEPRECATED EPICS_DEPRECATED + #if defined(__GNUC__) && !(defined(vxWorks) && !defined(_WRS_VXWORKS_MAJOR)) -#define USAGE_DEPRECATED __attribute__((deprecated)) #define USAGE_ERROR(MSG) __attribute__((error(MSG))) #else -#define USAGE_DEPRECATED #define USAGE_ERROR(MSG) { throw std::runtime_error(MSG); } #endif From 50b82137813067d15227c3580ce18a287e096bbd Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 5 Feb 2016 17:44:40 -0600 Subject: [PATCH 09/12] Fix NEED_OLL_FUNCS for windows-x64 and Base-3.15 --- src/misc/parseToPOD.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/misc/parseToPOD.cpp b/src/misc/parseToPOD.cpp index d0e3bcf..bac6509 100644 --- a/src/misc/parseToPOD.cpp +++ b/src/misc/parseToPOD.cpp @@ -251,7 +251,7 @@ epicsParseFloat(const char *str, float *to, char **units) // MS Visual Studio 2013 defines strtoll, etc. #if defined(_WIN32) && !defined(_MINGW) -# define NEED_OLL_FUNCS (_MSC_VER < 1800) +# define NEED_OLL_FUNCS (EPICS_VERSION_INT < VERSION_INT(3,15,0,1)) #elif defined(vxWorks) # define NEED_OLL_FUNCS !defined(_WRS_VXWORKS_MAJOR) #else From 47bb62b051a6307856ba6522b3298730ee8a23a3 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 11 Feb 2016 16:11:49 -0600 Subject: [PATCH 10/12] Disable another useless MSVC warning --- src/misc/pv/epicsException.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/misc/pv/epicsException.h b/src/misc/pv/epicsException.h index a5f9734..e1ba44d 100644 --- a/src/misc/pv/epicsException.h +++ b/src/misc/pv/epicsException.h @@ -64,7 +64,8 @@ #if defined(_WIN32) && !defined(_MINGW) #pragma warning( push ) -#pragma warning(disable: 4275) // warning C4275: non dll-interface class used as base for dll-interface class (std::logic_error) +#pragma warning(disable: 4275) // non dll-interface class used as base for dll-interface class (std::logic_error) +#pragma warning(disable: 4251) // class std::string needs to have dll-interface to be used by clients #endif namespace epics { namespace pvData { From 8d7f534d548c0cfa0c480e29105d8f3c83a98470 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 28 Mar 2016 17:11:25 -0500 Subject: [PATCH 11/12] VxWorks fix in parseToPOD.cpp --- src/misc/parseToPOD.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/misc/parseToPOD.cpp b/src/misc/parseToPOD.cpp index bac6509..b8eb552 100644 --- a/src/misc/parseToPOD.cpp +++ b/src/misc/parseToPOD.cpp @@ -27,7 +27,7 @@ using std::string; #endif #if EPICS_VERSION_INT < VERSION_INT(3,15,0,1) -/* integer conversion primitives added to epicsStdlib.c in 3.15.0.1 */ +/* These integer conversion primitives added to epicsStdlib.c in 3.15.0.1 */ #define S_stdlib_noConversion 1 /* No digits to convert */ #define S_stdlib_extraneous 2 /* Extraneous characters */ @@ -249,11 +249,11 @@ epicsParseFloat(const char *str, float *to, char **units) } #endif -// MS Visual Studio 2013 defines strtoll, etc. +// Sometimes we have to provide our own copy of strtoll() #if defined(_WIN32) && !defined(_MINGW) # define NEED_OLL_FUNCS (EPICS_VERSION_INT < VERSION_INT(3,15,0,1)) -#elif defined(vxWorks) -# define NEED_OLL_FUNCS !defined(_WRS_VXWORKS_MAJOR) +#elif defined(vxWorks) && !defined(_WRS_VXWORKS_MAJOR) +# define NEED_OLL_FUNCS 1 #else # define NEED_OLL_FUNCS 0 #endif @@ -307,7 +307,9 @@ noconvert: } #if defined(vxWorks) -/* vxworks version of std::istringstream >>uint64_t is buggy, we use out own implementation */ +/* The VxWorks version of std::istringstream >> uint64_t is buggy, + * provide our own implementation + */ static unsigned long long strtoull(const char *nptr, char **endptr, int base) { @@ -550,8 +552,9 @@ void parseToPOD(const string& in, double *out) { int err = epicsParseDouble(in.c_str(), out, NULL); if(err) handleParseError(err); #if defined(vxWorks) - /* vxWorks strtod returns [-]epicsINF when it should return ERANGE error - * if [-]epicsINF is returned and first char is a digit then translate this into ERANGE error + /* vxWorks strtod returns [-]epicsINF when it should return ERANGE error. + * If [-]epicsINF is returned and the first char is a digit we translate + * this into an ERANGE error */ else if (*out == epicsINF || *out == -epicsINF) { const char* s = in.c_str(); From 2ee8769752a50a2046f4a3f5a1c179be067ddb03 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 6 Apr 2016 15:29:30 -0500 Subject: [PATCH 12/12] Prevent redefinition of NOMINMAX While this protection is not strictly necessary here, if someone does a cut-and-paste into a header file it should be included. --- testApp/misc/testBitSet.cpp | 2 +- testApp/misc/testSerialization.cpp | 2 +- testApp/misc/testTypeCast.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/testApp/misc/testBitSet.cpp b/testApp/misc/testBitSet.cpp index 0a342fe..67b4036 100644 --- a/testApp/misc/testBitSet.cpp +++ b/testApp/misc/testBitSet.cpp @@ -6,7 +6,7 @@ */ /* Author: Matej Sekoranja Date: 2010.10.18 */ -#ifdef _WIN32 +#if defined(_WIN32) && !defined(NOMINMAX) #define NOMINMAX #endif diff --git a/testApp/misc/testSerialization.cpp b/testApp/misc/testSerialization.cpp index 797a26f..8f96619 100644 --- a/testApp/misc/testSerialization.cpp +++ b/testApp/misc/testSerialization.cpp @@ -10,7 +10,7 @@ * Author: Miha Vitorovic */ -#ifdef _WIN32 +#if defined(_WIN32) && !defined(NOMINMAX) #define NOMINMAX #endif diff --git a/testApp/misc/testTypeCast.cpp b/testApp/misc/testTypeCast.cpp index cab5fb7..5c5014c 100644 --- a/testApp/misc/testTypeCast.cpp +++ b/testApp/misc/testTypeCast.cpp @@ -5,7 +5,7 @@ */ /* Author: Michael Davidsaver */ -#ifdef _WIN32 +#if defined(_WIN32) && !defined(NOMINMAX) #define NOMINMAX #endif