I need to treat some specific warnings as errors to ensure the program runs as it is supposed to. For instance functions with [[nodiscard]] attribute should always return, otherwise the compiler prints an error. In Visual Studio (MSVC), it is easy to do that with:
#pragma warning (error: warning_id)
This works perfectly. But I run this code on a cluster, where I use either GCC, Clang or the Intel compiler, so I would like to implement this to be portable. Something like:
#if defined(_MSC_VER)
#pragma warning (error: 4834)
#elif defined(__GNUC__)
// what here?
#elif defined(__clang__)
// what to put here?
#else
// another compiler...
#endif
I suppose Intel is similar to MSVC; in Clang, there is an option to treat an error as warning -Wno-error=some_error, which would help me the other way around but there may be too many warnings, which I would rather not treat as errors.
Can anybody help with this?