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 ////////////////////////////////////////////////////////////