From fcb05fb975ee0df49aa1b9bdeb63e94bb43ffb23 Mon Sep 17 00:00:00 2001 From: Jan Haller Date: Sat, 19 Sep 2015 15:04:09 +0200 Subject: [PATCH] Added SFML_DEPRECATED macro for cross-platform class/function deprecation --- include/SFML/Config.hpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/include/SFML/Config.hpp b/include/SFML/Config.hpp index 05c7719ee..f5788dc0b 100644 --- a/include/SFML/Config.hpp +++ b/include/SFML/Config.hpp @@ -157,6 +157,44 @@ #endif +//////////////////////////////////////////////////////////// +// Cross-platform warning for deprecated functions and classes +// +// Usage: +// class SFML_DEPRECATED MyClass +// { +// SFML_DEPRECATED void memberFunc(); +// }; +// +// SFML_DEPRECATED void globalFunc(); +//////////////////////////////////////////////////////////// +#if defined(SFML_NO_DEPRECATED_WARNINGS) + + // User explicitly requests to disable deprecation warnings + #define SFML_DEPRECATED + +#elif defined(_MSC_VER) + + // Microsoft C++ compiler + // Note: On newer MSVC versions, using deprecated functions causes a compiler error. In order to + // trigger a warning instead of an error, the compiler flag /sdl- (instead of /sdl) must be specified. + #define SFML_DEPRECATED __declspec(deprecated) + +#elif defined(__GNUC__) + + // g++ and Clang + #define SFML_DEPRECATED __attribute__ ((deprecated)) + +#else + + // Other compilers are not supported, leave class or function as-is. + // With a bit of luck, the #pragma directive works, otherwise users get a warning (no error!) for unrecognized #pragma. + #pragma message("SFML_DEPRECATED is not supported for your compiler, please contact the SFML team") + #define SFML_DEPRECATED + +#endif + + //////////////////////////////////////////////////////////// // Define portable fixed-size types ////////////////////////////////////////////////////////////