From 7fc9b42b3ad1ee9794eb4822e3f7462122fe828c Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 22 Jun 2015 14:27:44 -0400 Subject: [PATCH] PVStructure: compiler warning when deprecated methods are used --- src/pv/pvData.h | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/pv/pvData.h b/src/pv/pvData.h index 575019a..32e4127 100644 --- a/src/pv/pvData.h +++ b/src/pv/pvData.h @@ -33,6 +33,14 @@ typedef class std::ios std::ios_base; #endif +#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 + namespace epics { namespace pvData { class PostHandler; @@ -709,84 +717,84 @@ public: * @param fieldName The name of the field to get. * @return Pointer to the field of null if a field with that name and type does not exist. */ - PVBooleanPtr getBooleanField(std::string const &fieldName) ; + PVBooleanPtr getBooleanField(std::string const &fieldName) USAGE_DEPRECATED; /** * Get a byte field with the specified name. * @deprecated No longer needed. Use templete version of getSubField * @param fieldName The name of the field to get. * @return Pointer to the field of null if a field with that name and type does not exist. */ - PVBytePtr getByteField(std::string const &fieldName) ; + PVBytePtr getByteField(std::string const &fieldName) USAGE_DEPRECATED; /** * Get a short field with the specified name. * @deprecated No longer needed. Use templete version of getSubField * @param fieldName The name of the field to get. * @return Pointer to the field of null if a field with that name and type does not exist. */ - PVShortPtr getShortField(std::string const &fieldName) ; + PVShortPtr getShortField(std::string const &fieldName) USAGE_DEPRECATED; /** * Get a int field with the specified name. * @deprecated No longer needed. Use templete version of getSubField * @param fieldName The name of the field to get. * @return Pointer to the field of null if a field with that name and type does not exist. */ - PVIntPtr getIntField(std::string const &fieldName) ; + PVIntPtr getIntField(std::string const &fieldName) USAGE_DEPRECATED; /** * Get a long field with the specified name. * @deprecated No longer needed. Use templete version of getSubField * @param fieldName The name of the field to get. * @return Pointer to the field of null if a field with that name and type does not exist. */ - PVLongPtr getLongField(std::string const &fieldName) ; + PVLongPtr getLongField(std::string const &fieldName) USAGE_DEPRECATED; /** * Get an unsigned byte field with the specified name. * @deprecated No longer needed. Use templete version of getSubField * @param fieldName The name of the field to get. * @return Pointer to the field of null if a field with that name and type does not exist. */ - PVUBytePtr getUByteField(std::string const &fieldName) ; + PVUBytePtr getUByteField(std::string const &fieldName) USAGE_DEPRECATED; /** * Get an unsigned short field with the specified name. * @deprecated No longer needed. Use templete version of getSubField * @param fieldName The name of the field to get. * @return Pointer to the field of null if a field with that name and type does not exist. */ - PVUShortPtr getUShortField(std::string const &fieldName) ; + PVUShortPtr getUShortField(std::string const &fieldName) USAGE_DEPRECATED; /** * Get an unsigned int field with the specified name. * @deprecated No longer needed. Use templete version of getSubField * @param fieldName The name of the field to get. * @return Pointer to the field of null if a field with that name and type does not exist. */ - PVUIntPtr getUIntField(std::string const &fieldName) ; + PVUIntPtr getUIntField(std::string const &fieldName) USAGE_DEPRECATED; /** * Get an unsigned long field with the specified name. * @deprecated No longer needed. Use templete version of getSubField * @param fieldName The name of the field to get. * @return Pointer to the field of null if a field with that name and type does not exist. */ - PVULongPtr getULongField(std::string const &fieldName) ; + PVULongPtr getULongField(std::string const &fieldName) USAGE_DEPRECATED; /** * Get a float field with the specified name. * @deprecated No longer needed. Use templete version of getSubField * @param fieldName The name of the field to get. * @return Pointer to the field of null if a field with that name and type does not exist. */ - PVFloatPtr getFloatField(std::string const &fieldName) ; + PVFloatPtr getFloatField(std::string const &fieldName) USAGE_DEPRECATED; /** * Get a double field with the specified name. * @deprecated No longer needed. Use templete version of getSubField * @param fieldName The name of the field to get. * @return Pointer to the field of null if a field with that name and type does not exist. */ - PVDoublePtr getDoubleField(std::string const &fieldName) ; + PVDoublePtr getDoubleField(std::string const &fieldName) USAGE_DEPRECATED; /** * Get a string field with the specified name. * @deprecated No longer needed. Use templete version of getSubField * @param fieldName The name of the field to get. * @return Pointer to the field of null if a field with that name and type does not exist. */ - PVStringPtr getStringField(std::string const &fieldName) ; + PVStringPtr getStringField(std::string const &fieldName) USAGE_DEPRECATED; /** * Get a structure field with the specified name. @@ -794,14 +802,14 @@ public: * @param fieldName The name of the field to get. * @return Pointer to the field of null if a field with that name and type does not exist. */ - PVStructurePtr getStructureField(std::string const &fieldName) ; + PVStructurePtr getStructureField(std::string const &fieldName) USAGE_DEPRECATED; /** * Get a union field with the specified name. * @deprecated No longer needed. Use templete version of getSubField * @param fieldName The name of the field to get. * @return Pointer to the field of null if a field with that name and type does not exist. */ - PVUnionPtr getUnionField(std::string const &fieldName) ; + PVUnionPtr getUnionField(std::string const &fieldName) USAGE_DEPRECATED; /** * Get a scalarArray field with the specified name. * @deprecated No longer needed. Use templete version of getSubField @@ -810,21 +818,21 @@ public: * @return Pointer to the field of null if a field with that name and type does not exist. */ PVScalarArrayPtr getScalarArrayField( - std::string const &fieldName,ScalarType elementType) ; + std::string const &fieldName,ScalarType elementType); /** * Get a structureArray field with the specified name. * @deprecated No longer needed. Use templete version of getSubField * @param fieldName The name of the field to get. * @return Pointer to the field of null if a field with that name and type does not exist. */ - PVStructureArrayPtr getStructureArrayField(std::string const &fieldName) ; + PVStructureArrayPtr getStructureArrayField(std::string const &fieldName) USAGE_DEPRECATED; /** * Get a unionArray field with the specified name. * @deprecated No longer needed. Use templete version of getSubField * @param fieldName The name of the field to get. * @return Pointer to the field of null if a field with that name and type does not exist. */ - PVUnionArrayPtr getUnionArrayField(std::string const &fieldName) ; + PVUnionArrayPtr getUnionArrayField(std::string const &fieldName) USAGE_DEPRECATED; /** * Serialize. * @param pbuffer The byte buffer. @@ -1621,6 +1629,9 @@ namespace std{ epicsShareExtern std::ostream& operator<<(std::ostream& o, const epics::pvData::PVField *ptr); } +#undef USAGE_DEPRECATED +#undef USAGE_ERROR + #endif /* PVDATA_H */ /** @page Overview Documentation