1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-03 22:13:11 +03:00

mbedtls: improve disabling -Wredundant-decls

Disable these warnings specifically for the mbedTLS public headers
and leave it on for the the rest of the code. This also fixes this
issue for autotools. Previous solution was globally disabling this
warning for the whole code when using mbedTLS and only with CMake.

Follow-up to 7ecc309cd1 #1224

Closes #1226
This commit is contained in:
Viktor Szakats
2023-11-17 20:04:52 +00:00
parent 64d6789f71
commit ecec68a2c1
2 changed files with 9 additions and 4 deletions

View File

@@ -387,10 +387,6 @@ if(CRYPTO_BACKEND STREQUAL "mbedTLS" OR NOT CRYPTO_BACKEND)
list(APPEND LIBRARIES ${MBEDTLS_LIBRARIES})
list(APPEND LIBSSH2_PC_LIBS_PRIVATE "-lmbedcrypto")
link_directories(${MBEDTLS_LIBRARY_DIR})
# mbedTLS (as of v3.5.1) has a duplicate function declaration
# in its own public headers. Disable the warning that detects it.
string(REGEX REPLACE "-Wredundant-decls" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
endif()
endif()

View File

@@ -46,7 +46,16 @@
#elif defined(LIBSSH2_LIBGCRYPT)
#include "libgcrypt.h"
#elif defined(LIBSSH2_MBEDTLS)
/* mbedTLS (as of v3.5.1) has a duplicate function declaration
in its own public headers. Disable the warning that detects it. */
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wredundant-decls"
#endif
#include "mbedtls.h"
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#elif defined(LIBSSH2_OS400QC3)
#include "os400qc3.h"
#elif defined(LIBSSH2_WINCNG)