Skip to content

Commit

Permalink
fix -Wcast-function-type build issues (#1972)
Browse files Browse the repository at this point in the history
silence -Werror,-Wcast-function-type-mismatch in crypto/rand_extra/windows.c.
extend -Wno-cast-function-type to clang versions supporting it.
Should address https://gitlab.gnome.org/GNOME/gnome-terminal/-/issues/96 also for clang builds.
Ref: Add a broader set of compile flags. #155
  • Loading branch information
vszakats authored Nov 8, 2024
1 parent 2d07d39 commit a11d73c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,10 @@ if(GCC OR CLANG)
endif()
set(C_CXX_FLAGS "${C_CXX_FLAGS} -Werror -Wformat=2 -Wsign-compare -Wmissing-field-initializers -Wwrite-strings")

if(GCC AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "8")
if((GCC AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "8") OR
(CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS "13"))
# GCC 8.x added a warning called -Wcast-function-type to the -Wextra umbrella.
# Also suppress for all clang versions supporting this warning.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-cast-function-type")
endif()

Expand Down
2 changes: 1 addition & 1 deletion crypto/rand_extra/windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static void init_processprng(void) {
if (hmod == NULL) {
abort();
}
g_processprng_fn = (ProcessPrngFunction)GetProcAddress(hmod, "ProcessPrng");
g_processprng_fn = (ProcessPrngFunction)(void(*)(void))GetProcAddress(hmod, "ProcessPrng");
if (g_processprng_fn == NULL) {
abort();
}
Expand Down

0 comments on commit a11d73c

Please sign in to comment.