From 1abdde0c3d43b7574b68920912ac2002afe8b85e Mon Sep 17 00:00:00 2001 From: jrowlandls Date: Fri, 16 Sep 2011 09:04:00 +0100 Subject: [PATCH] fixes for windows xp sp3 sdk 7.1, typedefs for non-portable types, removed variable-length stack allocated arrays in tests, fixed inconsistent timeFunction interface declaraion, replaced variable-length stack allocated array in with std::vector in PVStructure factory as it is followed immediately by further heap allocation --- pvDataApp/factory/PVDataCreateFactory.cpp | 3 +++ pvDataApp/factory/PVStructure.cpp | 5 +++-- pvDataApp/misc/CDRMonitor.cpp | 5 +++++ pvDataApp/misc/epicsException.h | 4 ++-- pvDataApp/misc/sharedPtr.h | 6 ++++++ pvDataApp/misc/timeFunction.cpp | 15 +-------------- testApp/misc/testLinkedList.cpp | 10 +++++----- testApp/misc/testQueue.cpp | 2 +- testApp/misc/testSerialization.cpp | 16 ++++++++-------- 9 files changed, 34 insertions(+), 32 deletions(-) diff --git a/pvDataApp/factory/PVDataCreateFactory.cpp b/pvDataApp/factory/PVDataCreateFactory.cpp index 34cb79e..2f031d0 100644 --- a/pvDataApp/factory/PVDataCreateFactory.cpp +++ b/pvDataApp/factory/PVDataCreateFactory.cpp @@ -4,6 +4,9 @@ * EPICS pvDataCPP is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. */ +#ifdef _WIN32 +#define NOMINMAX +#endif #include #include #include diff --git a/pvDataApp/factory/PVStructure.cpp b/pvDataApp/factory/PVStructure.cpp index df15472..869b69d 100644 --- a/pvDataApp/factory/PVStructure.cpp +++ b/pvDataApp/factory/PVStructure.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -150,9 +151,9 @@ namespace epics { namespace pvData { throw std::logic_error("Number of fields must be >=0"); Structure::shared_pointer structure = const_pointer_cast(getStructure()); - FieldConstPtr fields[numberNewFields]; + std::vector fields(numberNewFields); for(int i=0; igetField(); - structure->appendFields(numberNewFields,fields); + structure->appendFields(numberNewFields,&fields[0]); int origLength = pImpl->numberFields; PVFieldPtrArray oldPVFields = pImpl->pvFields; int numberFields = origLength + numberNewFields; diff --git a/pvDataApp/misc/CDRMonitor.cpp b/pvDataApp/misc/CDRMonitor.cpp index a71994e..9a14db4 100644 --- a/pvDataApp/misc/CDRMonitor.cpp +++ b/pvDataApp/misc/CDRMonitor.cpp @@ -19,6 +19,11 @@ #include #include +#ifdef _WIN32 +#include +typedef SSIZE_T ssize_t; +#endif + namespace epics { namespace pvData { static diff --git a/pvDataApp/misc/epicsException.h b/pvDataApp/misc/epicsException.h index 131fb80..d9fa691 100644 --- a/pvDataApp/misc/epicsException.h +++ b/pvDataApp/misc/epicsException.h @@ -84,7 +84,7 @@ public: } #elif defined(EXCEPT_USE_CAPTURE) { - m_depth=CaptureStackBackTrace(0,EXCEPT_DEPTH.m_stack,0); + m_depth=CaptureStackBackTrace(0,EXCEPT_DEPTH,m_stack,0); } #else {} @@ -141,7 +141,7 @@ namespace detail { std::string showException(const E& ex) { - ExceptionMixin *mx=dynamic_cast(&ex); + const ExceptionMixin *mx=dynamic_cast(&ex); if(!mx) return std::string(); return mx->show(); } diff --git a/pvDataApp/misc/sharedPtr.h b/pvDataApp/misc/sharedPtr.h index 9799f30..da070d5 100644 --- a/pvDataApp/misc/sharedPtr.h +++ b/pvDataApp/misc/sharedPtr.h @@ -35,6 +35,12 @@ # define SHARED_FROM_BOOST #endif +#if defined(_MSC_VER) && (_MSC_VER>=1600) +// MSVC 2010 has it in +# undef SHARED_FROM_BOOST +# undef SHARED_FROM_TR1 +#endif + // go and get it #if defined(SHARED_FROM_TR1) diff --git a/pvDataApp/misc/timeFunction.cpp b/pvDataApp/misc/timeFunction.cpp index 98d5bcd..3dfcd33 100644 --- a/pvDataApp/misc/timeFunction.cpp +++ b/pvDataApp/misc/timeFunction.cpp @@ -7,23 +7,10 @@ #include #include #include +#include namespace epics { namespace pvData { -class TimeFunctionRequester { -public: - virtual void function() = 0; -}; - -class TimeFunction : private NoDefaultMethods { -public: - TimeFunction(TimeFunctionRequester *requester); - ~TimeFunction(); - double timeCall(); -private: - TimeFunctionRequester *requester; -}; - TimeFunction::TimeFunction(TimeFunctionRequester *requester) : requester(requester) {} diff --git a/testApp/misc/testLinkedList.cpp b/testApp/misc/testLinkedList.cpp index c97c8af..ed2d655 100644 --- a/testApp/misc/testLinkedList.cpp +++ b/testApp/misc/testLinkedList.cpp @@ -28,7 +28,7 @@ using namespace epics::pvData; -static int numNodes = 5; +static const int numNodes = 5; class Basic; typedef LinkedListNode BasicListNode; typedef LinkedList BasicList; @@ -276,7 +276,7 @@ static void testOrderedQueue(FILE * fd ) { static void testTime(FILE *auxFd) { TimeStamp startTime; TimeStamp endTime; - int numNodes = 1000; + const int numNodes = 1000; LinkedList basicList; Basic *basics[numNodes]; @@ -309,7 +309,7 @@ static void testTimeLocked(FILE *auxFd) { TimeStamp startTime; TimeStamp endTime; Mutex mutex; - int numNodes = 1000; + const int numNodes = 1000; LinkedList basicList; Basic *basics[numNodes]; @@ -352,7 +352,7 @@ typedef std::list stdList; static void testStdListTime(FILE *auxFd) { TimeStamp startTime; TimeStamp endTime; - int numNodes = 1000; + const int numNodes = 1000; stdList basicList; Basic *basics[numNodes]; @@ -385,7 +385,7 @@ static void testStdListTime(FILE *auxFd) { static void testStdListTimeLocked(FILE *auxFd) { TimeStamp startTime; TimeStamp endTime; - int numNodes = 1000; + const int numNodes = 1000; Mutex mutex; stdList basicList; diff --git a/testApp/misc/testQueue.cpp b/testApp/misc/testQueue.cpp index c98363a..23440e5 100644 --- a/testApp/misc/testQueue.cpp +++ b/testApp/misc/testQueue.cpp @@ -36,7 +36,7 @@ struct Data { }; -static int numElements = 5; +static const int numElements = 5; typedef QueueElement DataElement; typedef Queue DataQueue; diff --git a/testApp/misc/testSerialization.cpp b/testApp/misc/testSerialization.cpp index 806b07e..b329d29 100644 --- a/testApp/misc/testSerialization.cpp +++ b/testApp/misc/testSerialization.cpp @@ -242,7 +242,7 @@ void testArray(std::ostream& ofile) { assert(factory!=NULL); ofile<<"\tPVBooleanArray\n"; - bool boolEmpty[] = { }; + bool boolEmpty[] = { false }; bool bv[] = { false, true, false, true, true }; PVBooleanArray* pvBoolean = (PVBooleanArray*)factory->createPVScalarArray( NULL, "pvBooleanArray", epics::pvData::pvBoolean); @@ -253,7 +253,7 @@ void testArray(std::ostream& ofile) { delete pvBoolean; ofile<<"\tPVByteArray\n"; - int8 byteEmpty[] = { }; + int8 byteEmpty[] = { 0 }; int8 byv[] = { 0, 1, 2, -1, BYTE_MAX_VALUE, BYTE_MAX_VALUE-1, BYTE_MIN_VALUE+1, BYTE_MIN_VALUE }; PVByteArray* pvByte = (PVByteArray*)factory->createPVScalarArray(NULL, @@ -265,7 +265,7 @@ void testArray(std::ostream& ofile) { delete pvByte; ofile<<"\tPVShortArray\n"; - int16 shortEmpty[] = { }; + int16 shortEmpty[] = { 0 }; int16 sv[] = { 0, 1, 2, -1, SHORT_MAX_VALUE, SHORT_MAX_VALUE-1, SHORT_MIN_VALUE+1, SHORT_MIN_VALUE }; PVShortArray* pvShort = (PVShortArray*)factory->createPVScalarArray(NULL, @@ -277,7 +277,7 @@ void testArray(std::ostream& ofile) { delete pvShort; ofile<<"\tPVIntArray\n"; - int32 intEmpty[] = { }; + int32 intEmpty[] = { 0 }; int32 iv[] = { 0, 1, 2, -1, INT_MAX_VALUE, INT_MAX_VALUE-1, INT_MIN_VALUE+1, INT_MIN_VALUE }; PVIntArray* pvInt = (PVIntArray*)factory->createPVScalarArray(NULL, @@ -289,7 +289,7 @@ void testArray(std::ostream& ofile) { delete pvInt; ofile<<"\tPVLongArray\n"; - int64 longEmpty[] = { }; + int64 longEmpty[] = { 0 }; int64 lv[] = { 0, 1, 2, -1, LONG_MAX_VALUE, LONG_MAX_VALUE-1, LONG_MIN_VALUE+1, LONG_MIN_VALUE }; PVLongArray* pvLong = (PVLongArray*)factory->createPVScalarArray(NULL, @@ -301,7 +301,7 @@ void testArray(std::ostream& ofile) { delete pvLong; ofile<<"\tPVFloatArray\n"; - float floatEmpty[] = { }; + float floatEmpty[] = { (float)0.0 }; float fv[] = { (float)0.0, (float)1.1, (float)2.3, (float)-1.4, FLOAT_MAX_VALUE, FLOAT_MAX_VALUE-(float)123456.789, FLOAT_MIN_VALUE +(float)1.1, FLOAT_MIN_VALUE }; @@ -314,7 +314,7 @@ void testArray(std::ostream& ofile) { delete pvFloat; ofile<<"\tPVDoubleArray\n"; - double doubleEmpty[] = { }; + double doubleEmpty[] = { (double)0.0 }; double dv[] = { (double)0.0, (double)1.1, (double)2.3, (double)-1.4, DOUBLE_MAX_VALUE, DOUBLE_MAX_VALUE-(double)123456.789, DOUBLE_MIN_VALUE+(double)1.1, DOUBLE_MIN_VALUE }; @@ -327,7 +327,7 @@ void testArray(std::ostream& ofile) { delete pvDouble; ofile<<"\tPVStringArray\n"; - String stringEmpty[] = { }; + String stringEmpty[] = { "" }; String strv[] = {