From c963db66bb17bae35d03ce9557c31649d3e9c9e4 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 12 Feb 2025 16:22:16 +0100 Subject: [PATCH] Avoid redefinition warning for `OPENSSL_API_COMPAT` (#5646) Signed-off-by: Miguel Company (cherry picked from commit e0c453b0ca70ef54fe9dfa0e6031c48cc6446d2f) --- src/cpp/rtps/transport/TCPAcceptorSecure.h | 3 +++ src/cpp/rtps/transport/TCPChannelResourceSecure.h | 3 +++ src/cpp/rtps/transport/TCPTransportInterface.h | 8 +++++++- src/cpp/security/artifact_providers/Pkcs11Provider.cpp | 3 +++ src/cpp/security/authentication/PKIDH.cpp | 3 +++ .../security/authentication/BuiltinPKIDHTests.cpp | 3 +++ 6 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/cpp/rtps/transport/TCPAcceptorSecure.h b/src/cpp/rtps/transport/TCPAcceptorSecure.h index 6058a4b4f00..f189681d4b4 100644 --- a/src/cpp/rtps/transport/TCPAcceptorSecure.h +++ b/src/cpp/rtps/transport/TCPAcceptorSecure.h @@ -15,6 +15,9 @@ #ifndef _FASTDDS_TCP_ACCEPTOR_SECURE_ #define _FASTDDS_TCP_ACCEPTOR_SECURE_ +#ifdef OPENSSL_API_COMPAT +#undef OPENSSL_API_COMPAT +#endif // ifdef OPENSSL_API_COMPAT #define OPENSSL_API_COMPAT 10101 #include diff --git a/src/cpp/rtps/transport/TCPChannelResourceSecure.h b/src/cpp/rtps/transport/TCPChannelResourceSecure.h index 8d12d8ea219..76164acafb6 100644 --- a/src/cpp/rtps/transport/TCPChannelResourceSecure.h +++ b/src/cpp/rtps/transport/TCPChannelResourceSecure.h @@ -15,6 +15,9 @@ #ifndef _FASTDDS_TCP_CHANNEL_RESOURCE_SECURE_ #define _FASTDDS_TCP_CHANNEL_RESOURCE_SECURE_ +#ifdef OPENSSL_API_COMPAT +#undef OPENSSL_API_COMPAT +#endif // ifdef OPENSSL_API_COMPAT #define OPENSSL_API_COMPAT 10101 #include diff --git a/src/cpp/rtps/transport/TCPTransportInterface.h b/src/cpp/rtps/transport/TCPTransportInterface.h index 147a2fdb640..ba4a1d7997b 100644 --- a/src/cpp/rtps/transport/TCPTransportInterface.h +++ b/src/cpp/rtps/transport/TCPTransportInterface.h @@ -15,6 +15,13 @@ #ifndef _FASTDDS_TCP_TRANSPORT_INTERFACE_H_ #define _FASTDDS_TCP_TRANSPORT_INTERFACE_H_ +#if TLS_FOUND +#ifdef OPENSSL_API_COMPAT +#undef OPENSSL_API_COMPAT +#endif // ifdef OPENSSL_API_COMPAT +#define OPENSSL_API_COMPAT 10101 +#endif // if TLS_FOUND + #include #include #include @@ -35,7 +42,6 @@ #include #if TLS_FOUND -#define OPENSSL_API_COMPAT 10101 #include #include #endif // if TLS_FOUND diff --git a/src/cpp/security/artifact_providers/Pkcs11Provider.cpp b/src/cpp/security/artifact_providers/Pkcs11Provider.cpp index 05bab96dbfa..877b40c3eef 100644 --- a/src/cpp/security/artifact_providers/Pkcs11Provider.cpp +++ b/src/cpp/security/artifact_providers/Pkcs11Provider.cpp @@ -18,6 +18,9 @@ // TODO This isn't a proper fix for compatibility with OpenSSL 3.0, but // suppresses the warnings until true OpenSSL 3.0 APIs can be used. +#ifdef OPENSSL_API_COMPAT +#undef OPENSSL_API_COMPAT +#endif // ifdef OPENSSL_API_COMPAT #define OPENSSL_API_COMPAT 10101 #include diff --git a/src/cpp/security/authentication/PKIDH.cpp b/src/cpp/security/authentication/PKIDH.cpp index 0ebe99bc2ef..bb10c4dd41f 100644 --- a/src/cpp/security/authentication/PKIDH.cpp +++ b/src/cpp/security/authentication/PKIDH.cpp @@ -18,6 +18,9 @@ // TODO This isn't a proper fix for compatibility with OpenSSL 3.0, but // suppresses the warnings until true OpenSSL 3.0 APIs can be used. +#ifdef OPENSSL_API_COMPAT +#undef OPENSSL_API_COMPAT +#endif // ifdef OPENSSL_API_COMPAT #define OPENSSL_API_COMPAT 10101 #include diff --git a/test/unittest/security/authentication/BuiltinPKIDHTests.cpp b/test/unittest/security/authentication/BuiltinPKIDHTests.cpp index 5ce715ae0cd..ab0dcc91e31 100644 --- a/test/unittest/security/authentication/BuiltinPKIDHTests.cpp +++ b/test/unittest/security/authentication/BuiltinPKIDHTests.cpp @@ -14,6 +14,9 @@ // TODO This isn't a proper fix for compatibility with OpenSSL 3.0, but // suppresses the warnings until true OpenSSL 3.0 APIs can be used. +#ifdef OPENSSL_API_COMPAT +#undef OPENSSL_API_COMPAT +#endif // ifdef OPENSSL_API_COMPAT #define OPENSSL_API_COMPAT 10101 #include