Hide unused variable warnings in git error strings

These strings aren't actually used right now, but they may be used
in the future, so don't actually remove them but silence the error that
they aren't used.
This commit is contained in:
Ian McInerney 2023-12-19 15:19:57 +00:00
parent 687389224e
commit 3a90b729ea
3 changed files with 25 additions and 1 deletions

View File

@ -184,6 +184,14 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set( HAVE_WIMPLICIT_FLOAT_CONVERSION true )
endif()
# See if the compiler will throw warnings on these conversions
CHECK_CXX_COMPILER_FLAG( "-Wunused-const-variable" COMPILER_SUPPORTS_WUNUSED_CONST_VARIABLE )
if( COMPILER_SUPPORTS_WUNUSED_CONST_VARIABLE )
# This one is different, it is used to guard warning removal for this inside the code
set( HAVE_WUNUSED_CONST_VARIABLE true )
endif()
# Suppress GCC warnings about unknown/unused attributes (e.g. cdecl, [[maybe_unused, etc)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes" )

View File

@ -57,6 +57,9 @@
#define strncasecmp strnicmp
#endif
// Does the compiler support the -Wunused-const-variable warning
#cmakedefine HAVE_WUNUSED_CONST_VARIABLE
// Does the compiler support the -Wimplicit-int-float-conversion warning
#cmakedefine HAVE_WIMPLICIT_FLOAT_CONVERSION

View File

@ -21,6 +21,15 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
// None of these values are currently used, but Seth says they may be used in the future,
// so for now, just surpress the warning that is generated by the fact they exist and aren't
// used anywhere.
#ifdef HAVE_WUNUSED_CONST_VARIABLE
_Pragma( "GCC diagnostic push" ) \
_Pragma( "GCC diagnostic ignored \"-Wunused-const-variable\"" )
#endif
namespace KIGIT_ERROR
{
#undef _
@ -63,4 +72,8 @@ namespace KIGIT_ERROR
const char* const kUnknownError = _("Unknown error.");
const char* const kNoError = _("No error.");
}
}
#ifdef HAVE_WUNUSED_CONST_VARIABLE
_Pragma( "GCC diagnostic pop" )
#endif