c++ - Error when compiling cpp file with g++ -
i have centos 7 install running gcc 4.8.5 , can compile cpp file named myclass. use following command compile file:
g++ -c -fpermissive $(pkg-config --cflags --libs libavformat libavcodec libswscale libavutil) ./myclass.cpp when run command on centos 6.7 running gcc 4.4.7, following error:
in file included ./myclass.cpp:9: ./myclass.h:70: warning: iso c++ forbids initialization of member ‘pformatctx’ ./myclass.h:70: warning: making ‘pformatctx’ static ./myclass.h:70: error: invalid in-class initialization of static data member of non-integral type ‘avformatcontext*’ in myclass.h file, have private variable:
avformatcontext *pformatctx = null; this error repeated of private variables initialize null.
is there explanation difference encountering between 2 centos installs?
this complete class:
// // myclass.h // ffmpegplayground // #ifndef __ffmpegplayground__myclass__ #define __ffmpegplayground__myclass__ #include <stdio.h> #ifndef int64_c #define int64_c(c) (c ## ll) #define uint64_c(c) (c ## ull) #endif #ifdef __cplusplus #define __stdint_macros #endif extern "c" { #include <libavformat/avformat.h> #include <libavcodec/avcodec.h> #include <libswscale/swscale.h> #include <libavutil/frame.h> } typedef enum { k_status_ok = 0, k_cant_open_file = -1, k_no_stream_info = -2, k_no_video_stream = -3, k_codec_unsupported = -4, k_cant_copy_codec = -5, k_cant_open_codec = -6, k_cant_allocate_frame = -7, k_seek_failed = -8, k_unable_to_acquire_frame = -9 } myclassstatus; class myclass{ public: myclass(); myclass(const char * filepath); myclass(const char * filepath, double nscale); ~myclass(); myclassstatus getstatus(); void seektoframe(int frame); uint8_t* framedata(); uint8_t* nextframedata(); uint8_t* copyofnextframedata(); int getframeheight(); int getframewidth(); int getcurrentframe(); int getframedatasize(); long long getnumberofframes(); private: bool fileisloaded; uint8_t* createframe(); int currentframe; void internalseektoframe(int frame); myclassstatus status; avformatcontext *pformatctx = null; int i, videostream; avcodeccontext *pcodecctxorig = null; avcodeccontext *pcodecctx = null; avcodec *pcodec = null; avframe *pframe = null; avframe *pframergb = null; int numbytes; uint8_t *buffer = null; struct swscontext *sws_ctx = null; uint8_t *_createdframedata = null; double preferredscale = 1.0; }; #endif /* defined(__ffmpegplayground__myclass__) */
in-class initializers non-static members like
avformatcontext *pformatctx = null; are c++11 feature. gcc4.4 old that.
Comments
Post a Comment