From 4e566656574787472162d7a09bd4460d1ff1e033 Mon Sep 17 00:00:00 2001 From: Jasmin Jessich Date: Sun, 21 May 2017 19:44:02 +0200 Subject: Use "std::unique_ptr" instead of "std::auto_ptr" - Compile plugin with C++11 compiler, to allow usage of "std::unique_ptr". - Added "-Wfatal-errors -Wall" to stop on the first error and switch on all warnings. - Removed autoptr.h and used "std::unique_ptr" instead where macro AUTO_PTR has been used. Checked also, if the pointers are used correctly, because "std::unique_ptr" is not 100% compatible to "std::auto_ptr", when the pointer is "moved". "std::unique_ptr" needs an explicit call to "std::move" in this case (AFAIU). Keep "std::auto_ptr" in the epgsearch interface! --- Makefile | 2 ++ autoptr.h | 16 ---------------- epgsearch/services.h | 11 +++++------ grab.h | 5 +++-- live.h | 2 +- pages/edit_timer.ecpp | 3 +-- thread.h | 5 +++-- timers.cpp | 4 ++-- 8 files changed, 17 insertions(+), 31 deletions(-) delete mode 100644 autoptr.h diff --git a/Makefile b/Makefile index 4121913..0b0b95f 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,8 @@ ifneq ($(HAVE_LIBPCRECPP),) LIBS += $(HAVE_LIBPCRECPP) endif +CXXFLAGS += -std=c++11 -Wfatal-errors -Wall # -Werror + ### export all vars for sub-makes, using absolute paths LIBDIR := $(shell cd $(LIBDIR) >/dev/null 2>&1 && pwd) LOCDIR := $(shell cd $(LOCDIR) >/dev/null 2>&1 && pwd) diff --git a/autoptr.h b/autoptr.h deleted file mode 100644 index 4dc0263..0000000 --- a/autoptr.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef VDR_LIVE_AUTOPTR_H -#define VDR_LIVE_AUTOPTR_H - -#define GCC_VERSION (__GNUC__ * 10000 \ - + __GNUC_MINOR__ * 100 \ - + __GNUC_PATCHLEVEL__) - -# include - -#if GCC_VERSION > 50000 -# define AUTO_PTR std::unique_ptr -#else -# define AUTO_PTR std::auto_ptr -#endif - -#endif // VDR_LIVE_AUTOPTR_H diff --git a/epgsearch/services.h b/epgsearch/services.h index fee274e..9136c51 100644 --- a/epgsearch/services.h +++ b/epgsearch/services.h @@ -24,12 +24,11 @@ The project's page is at http://winni.vdr-developer.org/epgsearch #ifndef EPGSEARCHSERVICES_INC #define EPGSEARCHSERVICES_INC -#include "../autoptr.h" - -// STL headers need to be before VDR tools.h (included by ) +// STL headers need to be before VDR tools.h (included by ) #include #include #include +#include #include @@ -161,7 +160,7 @@ class cServiceHandler struct Epgsearch_services_v1_0 { // in/out - AUTO_PTR handler; + std::auto_ptr handler; }; // Data structures for service "Epgsearch-services-v1.1" @@ -177,7 +176,7 @@ class cServiceHandler_v1_1 : public cServiceHandler struct Epgsearch_services_v1_1 { // in/out - AUTO_PTR handler; + std::auto_ptr handler; }; // Data structures for service "Epgsearch-services-v1.2" @@ -193,7 +192,7 @@ class cServiceHandler_v1_2 : public cServiceHandler_v1_1 struct Epgsearch_services_v1_2 { // in/out - AUTO_PTR handler; + std::auto_ptr handler; }; #endif diff --git a/grab.h b/grab.h index 3895e9d..fb0fcfc 100644 --- a/grab.h +++ b/grab.h @@ -2,7 +2,8 @@ #define VDR_LIVE_GRAB_H #include "stdext.h" -#include "autoptr.h" + +#include namespace vdrlive { @@ -28,7 +29,7 @@ private: void PutImage( char* image, int size ); - AUTO_PTR< GrabImageTask > m_task; + std::unique_ptr< GrabImageTask > m_task; GrabImagePtr m_image; int m_size; }; diff --git a/live.h b/live.h index bf874be..24b981d 100644 --- a/live.h +++ b/live.h @@ -38,7 +38,7 @@ private: static std::string m_configDirectory; static std::string m_resourceDirectory; - AUTO_PTR< ServerThread > m_thread; + std::unique_ptr< ServerThread > m_thread; }; } // namespace vdrlive diff --git a/pages/edit_timer.ecpp b/pages/edit_timer.ecpp index d080ee5..9a7dfd3 100644 --- a/pages/edit_timer.ecpp +++ b/pages/edit_timer.ecpp @@ -8,7 +8,6 @@ #include #include #include -#include #include @@ -103,7 +102,7 @@ cTimer* timer; if (message.empty()) edit_timerreferer = request.getHeader("Referer:", "timers.html"); - AUTO_PTR< cTimer > eventTimer; + std::unique_ptr< cTimer > eventTimer; if ( timer == 0 && !epgid.empty()) { EpgEvents::DecodeDomId(epgid, channelid, eventid); if ( channelid.Valid() && eventid != 0 ) { diff --git a/thread.h b/thread.h index cbe0e9c..210194f 100644 --- a/thread.h +++ b/thread.h @@ -1,9 +1,10 @@ #ifndef VDR_LIVE_THREAD_H #define VDR_LIVE_THREAD_H -#include "autoptr.h" #include +#include + namespace tnt { class Tntnet; } namespace vdrlive { @@ -19,7 +20,7 @@ protected: virtual void Action(); private: - AUTO_PTR< tnt::Tntnet > m_server; + std::unique_ptr< tnt::Tntnet > m_server; }; } // namespace vdrlive diff --git a/timers.cpp b/timers.cpp index bf954fc..8f3eea8 100644 --- a/timers.cpp +++ b/timers.cpp @@ -3,10 +3,10 @@ #include "exception.h" #include "tools.h" -#include "autoptr.h" // STL headers need to be before VDR tools.h (included by ) #include +#include #include #include @@ -279,7 +279,7 @@ namespace vdrlive { void TimerManager::DoInsertTimer( TimerPair& timerData ) { - AUTO_PTR< cTimer > newTimer( new cTimer ); + std::unique_ptr< cTimer > newTimer( new cTimer ); if ( !newTimer->Parse( timerData.second.c_str() ) ) { StoreError( timerData, tr("Error in timer settings") ); return; -- cgit v1.2.3