core: add macro to silence 'maybe uninitialized' warnings

This commit is contained in:
Tommaso Pecorella
2024-03-25 21:43:43 +01:00
parent 61b5fad814
commit 41921f6e81

View File

@@ -48,6 +48,13 @@
* \sa NS_WARNING_POP
*/
/**
* \ingroup warnings
* \def NS_WARNING_SILENCE_MAYBE_UNINITIALIZED
* Silences GCC "-Wmaybe-uninitialized" warnings.
* \sa NS_WARNING_POP
*/
/**
* \ingroup warnings
* \def NS_WARNING_PUSH_DEPRECATED
@@ -62,9 +69,30 @@
* NS_WARNING_POP;
* \endcode
*
* This macro is equivalent to
* \code
* NS_WARNING_PUSH;
* NS_WARNING_SILENCE_DEPRECATED;
* \endcode
*
* Its use is, of course, not suggested unless strictly necessary.
*/
/**
* \ingroup warnings
* \def NS_WARNING_PUSH_MAYBE_UNINITIALIZED
* Save the current warning list and disables the ones about possible uninitialized variables.
*
*
* This macro is equivalent to
* \code
* NS_WARNING_PUSH;
* NS_WARNING_SILENCE_MAYBE_UNINITIALIZED;
* \endcode
*
* \sa NS_WARNING_PUSH_DEPRECATED
*/
#if defined(_MSC_VER)
// You can find the MSC warning codes at
// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warnings-c4000-c5999
@@ -86,8 +114,20 @@
#endif
// GCC-specific - Apple's clang pretends to be both...
#if defined(__GNUC__) && !defined(__clang__)
#define NS_WARNING_SILENCE_MAYBE_UNINITIALIZED \
_Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
#else
#define NS_WARNING_SILENCE_MAYBE_UNINITIALIZED
#endif
#define NS_WARNING_PUSH_DEPRECATED \
NS_WARNING_PUSH; \
NS_WARNING_SILENCE_DEPRECATED
#define NS_WARNING_PUSH_MAYBE_UNINITIALIZED \
NS_WARNING_PUSH; \
NS_WARNING_SILENCE_MAYBE_UNINITIALIZED
#endif /* NS3_WARNINGS_H */