mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-31 02:35:46 +01:00
Set -Wmissing-prototypes for clang builds (#24757)
* Set -Wmissing-prototypes for clang builds. GCC defines -Wmissing-declarations as specialization of -Wmissing-prototypes for C++ (See https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmissing-declarations and https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmissing-prototypes) while Clang uses -Wmissing-prototypes for both languages and -Wmissing-declarations is a different diagnostic (See https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-prototypes and https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-declarations). Use MATCHES against CMAKE_CXX_COMPILER_ID (See https://stackoverflow.com/a/10055571, https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html) as conditional to handle both AppleClang and Clang. Clang enables -Wmissing-declarations by default so no point in setting it only if !Clang. See also: https://github.com/llvm/llvm-project/issues/16660 https://reviews.llvm.org/D119361 * Make HasMatchingLanguage in Platform.macOS.mm static. Uncovered by setting -Wmissing-prototypes flag for Clang builds in306c277c. * Ignore -Wmissing-prototypes for extern GetVersion. Result of setting -Wmissing-prototypes flag for Clang builds in306c277c. See also: https://github.com/llvm/llvm-project/issues/94138
This commit is contained in:
@@ -358,6 +358,11 @@ else ()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=objc-method-access")
|
||||
endif()
|
||||
|
||||
# Clang -Wmissing-declarations differs from GCC, set -Wmissing-prototypes for parity
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmissing-prototypes")
|
||||
endif()
|
||||
|
||||
# On mingw all code is already PIC, this will avoid compiler error on redefining this option
|
||||
if (NOT MINGW)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
@@ -56,13 +56,19 @@ const char gVersionInfoFull[] = OPENRCT2_NAME ", "
|
||||
;
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
// This must be wrapped in extern "C", according to the emscripten docs, "to prevent C++ name mangling"
|
||||
// This must be wrapped in extern "C", according to the emscripten docs, "to prevent C++ name mangling"
|
||||
// Ignore -Wmissing-prototypes here, see https://github.com/llvm/llvm-project/issues/94138
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
extern "C" {
|
||||
const char* GetVersion()
|
||||
{
|
||||
return gVersionInfoFull;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
NewVersionInfo GetLatestVersion()
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace OpenRCT2::Platform
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HasMatchingLanguage(NSString* preferredLocale, uint16_t* languageIdentifier)
|
||||
static bool HasMatchingLanguage(NSString* preferredLocale, uint16_t* languageIdentifier)
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user