c++ - How to detect declaration of class at compile-time? -


i'm use 3-rd party library @ project. after updating new version of library i'm faced errors.

one class have method

virtual rtspserver::rtspclientsession* createnewclientsession(u_int32_t sessionid)override; 

but in new version of library declaration of rtspclientsession moved class , renamed. correct name

genericmediaserver::clientsession 

i need code correctly compiles versions of library.

at gcc use following code:

#ifdef rtspserver::rtspclientsession     using clientsessionclass = rtspserver::rtspclientsession; #else     using clientsessionclass = genericmediaserver::clientsession; #endif  class {     .........     virtual clientsessionclass* createnewclientsession(u_int32_t sessionid)override; }; 

but not work in msvc 2010. how can detect declaration should use?

upd: code gcc don't work old version of library :(

"how can detect declaration should use?"

you need introduce discriminator library version you're using current build configuration:

#ifdef old_library_version // maybe binding headers have information this.                            // if not have select manually, , provide                             // setting project configuration.    using clientsessionclass = rtspserver::rtspclientsession; #else    using clientsessionclass = genericmediaserver::clientsession; #endif 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -