Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/Corrade/Utility/DeprecationMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,16 @@ On compilers other than GCC, Clang and MSVC the macro does nothing.
@ref CORRADE_DEPRECATED_FILE()
*/
#ifndef CORRADE_DEPRECATED_MACRO
#ifdef CORRADE_TARGET_CLANG
#define CORRADE_DEPRECATED_MACRO(macro,message) _Pragma(_CORRADE_HELPER_STR(GCC warning ("this macro is deprecated: " message)))
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 14
#define CORRADE_DEPRECATED_MACRO(macro, message) _Pragma(_CORRADE_HELPER_STR(clang deprecated(macro, message)))
#elif defined(CORRADE_TARGET_CLANG)
#define CORRADE_DEPRECATED_MACRO(macro, message) _Pragma(_CORRADE_HELPER_STR(GCC warning ("this macro is deprecated: " message)))
#elif defined(CORRADE_TARGET_GCC)
#define CORRADE_DEPRECATED_MACRO(macro,message) _Pragma(_CORRADE_HELPER_STR(GCC warning message))
#define CORRADE_DEPRECATED_MACRO(macro, message) _Pragma(_CORRADE_HELPER_STR(GCC warning message))
#elif defined(CORRADE_TARGET_MSVC)
#define CORRADE_DEPRECATED_MACRO(macro,_message) __pragma(message (__FILE__ ": warning: " _CORRADE_HELPER_STR(macro) " is deprecated: " _message))
#define CORRADE_DEPRECATED_MACRO(macro, _message) __pragma(message (__FILE__ ": warning: " _CORRADE_HELPER_STR(macro) " is deprecated: " _message))
#else
#define CORRADE_DEPRECATED_MACRO(macro,message)
#define CORRADE_DEPRECATED_MACRO(macro, message)
#endif
#endif

Expand Down
4 changes: 3 additions & 1 deletion src/Corrade/Utility/Test/DeprecationMacrosTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace CORRADE_DEPRECATED_NAMESPACE("use Namespace instead") DeprecatedNamesp
}
#define MACRO(foo) do {} while(false)
#define DEPRECATED_MACRO(foo) \
CORRADE_DEPRECATED_MACRO(DEPRECATED_MACRO(),"ignore me, I'm just testing the CORRADE_DEPRECATED_MACRO() macro") MACRO(foo)
CORRADE_DEPRECATED_MACRO(DEPRECATED_MACRO, "ignore me, I'm just testing the CORRADE_DEPRECATED_MACRO() macro") MACRO(foo)

/* Uncomment to test various subsets of deprecation warnings */
// #define ENABLE_DEPRECATION_WARNINGS
Expand Down Expand Up @@ -174,6 +174,8 @@ void DeprecationMacrosTest::deprecatedMacro() {
/* Warning on MSVC, GCC, Clang. Can only be disabled with
CORRADE_IGNORE_DEPRECATED_PUSH on Clang, not on GCC or MSVC. */
DEPRECATED_MACRO(hello?);
// TODO argh the above doesn't warn, only a subsequent use of the same macro, what to do?!
DEPRECATED_MACRO(now it does);

CORRADE_VERIFY(true);
}
Expand Down