Skip to content

Commit 00ec094

Browse files
SergeyRyabininSergey Ryabinin
and
Sergey Ryabinin
authored
Fixes for building with mingw #3319 #3315 (#3385)
Co-authored-by: Sergey Ryabinin <[email protected]>
1 parent 0a95ac0 commit 00ec094

File tree

11 files changed

+36
-9
lines changed

11 files changed

+36
-9
lines changed

.cspell.json

+2
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@
148148
"gnustl",
149149
"libgnustl",
150150
"Wmissing",
151+
"Wmaybe",
152+
"Wuninitialized",
151153
// Android NDK
152154
"JNIEXPORT",
153155
"jint",

cmake/compiler_settings.cmake

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ else()
1111
set(COMPILER_CLANG 1)
1212
else()
1313
set(COMPILER_GCC 1)
14+
if(MINGW)
15+
set(COMPILER_MINGW 1)
16+
endif()
1417
endif()
1518
set(USE_GCC_FLAGS 1)
1619
endif()
@@ -34,6 +37,9 @@ endfunction()
3437

3538
macro(set_gcc_flags)
3639
list(APPEND AWS_COMPILER_FLAGS "-fno-exceptions" "-std=c++${CPP_STANDARD}")
40+
if(COMPILER_IS_MINGW)
41+
list(APPEND AWS_COMPILER_FLAGS -D__USE_MINGW_ANSI_STDIO=1)
42+
endif()
3743

3844
if(NOT BUILD_SHARED_LIBS)
3945
list(APPEND AWS_COMPILER_FLAGS "-fPIC")

src/aws-cpp-sdk-core/include/aws/core/utils/event/EventHeader.h

+10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
#include <aws/event-stream/event_stream.h>
1717
#include <cassert>
1818

19+
#ifdef __MINGW32__
20+
#pragma GCC diagnostic push
21+
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
22+
#pragma GCC diagnostic ignored "-Wuninitialized"
23+
#endif
24+
1925
namespace Aws
2026
{
2127
namespace Utils
@@ -350,3 +356,7 @@ namespace Aws
350356
}
351357
}
352358
}
359+
360+
#ifdef __MINGW32__
361+
#pragma GCC diagnostic pop
362+
#endif

src/aws-cpp-sdk-core/source/http/windows/WinHttpSyncHttpClient.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <aws/core/utils/ratelimiter/RateLimiterInterface.h>
1818
#include <aws/core/utils/UnreferencedParam.h>
1919

20-
#include <Windows.h>
20+
#include <winsock2.h>
2121
#include <winhttp.h>
2222
#include <mstcpip.h> // for tcp_keepalive
2323
#include <sstream>
@@ -696,7 +696,7 @@ bool WinHttpSyncHttpClient::DoQueryHeaders(void* hHttpRequest, std::shared_ptr<H
696696
wmemset(contentTypeStr, 0, static_cast<size_t>(dwSize / sizeof(wchar_t)));
697697

698698
WinHttpQueryHeaders(hHttpRequest, WINHTTP_QUERY_CONTENT_TYPE, nullptr, &contentTypeStr, &dwSize, 0);
699-
if (contentTypeStr[0] != NULL)
699+
if (contentTypeStr[0])
700700
{
701701
Aws::String contentStr = StringUtils::FromWString(contentTypeStr);
702702
response->SetContentType(contentStr);
@@ -727,7 +727,7 @@ bool WinHttpSyncHttpClient::DoQueryHeaders(void* hHttpRequest, std::shared_ptr<H
727727

728728
bool WinHttpSyncHttpClient::DoSendRequest(void* hHttpRequest) const
729729
{
730-
bool success = WinHttpSendRequest(hHttpRequest, NULL, NULL, 0, 0, 0, NULL) != 0;
730+
bool success = WinHttpSendRequest(hHttpRequest, NULL, 0, NULL, 0, 0, 0) != 0;
731731
if (!success)
732732
{
733733
AzWinHttpLogLastError("WinHttpSendRequest");

src/aws-cpp-sdk-core/source/http/windows/WinINetSyncHttpClient.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ bool WinINetSyncHttpClient::DoQueryHeaders(void* hHttpRequest, std::shared_ptr<H
227227
char contentTypeStr[1024];
228228
dwSize = sizeof(contentTypeStr);
229229
HttpQueryInfoA(hHttpRequest, HTTP_QUERY_CONTENT_TYPE, &contentTypeStr, &dwSize, 0);
230-
if (contentTypeStr[0] != NULL)
230+
if (contentTypeStr[0])
231231
{
232232
response->SetContentType(contentTypeStr);
233233
AWS_LOGSTREAM_DEBUG(GetLogTag(), "Received content type " << contentTypeStr);

src/aws-cpp-sdk-core/source/platform/windows/FileSystem.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
#include <iostream>
1313
#include <Userenv.h>
1414

15-
#pragma warning( disable : 4996)
15+
#ifdef _MSC_VER
16+
#pragma warning(disable: 4996)
17+
#endif
1618

1719
using namespace Aws::Utils;
1820
namespace Aws
@@ -311,6 +313,9 @@ Aws::String CreateTempFilePath()
311313
{
312314
#ifdef _MSC_VER
313315
#pragma warning(disable: 4996) // _CRT_SECURE_NO_WARNINGS
316+
#elif !defined(L_tmpnam_s)
317+
// Definition from the MSVC stdio.h
318+
#define L_tmpnam_s (sizeof("\\") + 16)
314319
#endif
315320
char s_tempName[L_tmpnam_s+1];
316321

src/aws-cpp-sdk-core/source/platform/windows/OSVersionInfo.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
#include <iomanip>
1111

12+
#ifdef _MSC_VER
1213
#pragma warning(disable: 4996)
14+
#endif
1315
#include <windows.h>
1416
#include <stdio.h>
1517
namespace Aws

src/aws-cpp-sdk-core/source/utils/crypto/factory/Factories.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ std::shared_ptr<Aws::Utils::Crypto::HMAC> Aws::Utils::Crypto::CreateSha256HMACIm
809809
return GetSha256HMACFactory()->CreateImplementation();
810810
}
811811

812-
#ifdef _WIN32
812+
#ifdef _MSC_VER
813813
#pragma warning( push )
814814
#pragma warning( disable : 4702 )
815815
#endif
@@ -902,7 +902,7 @@ std::shared_ptr<SymmetricCipher> Aws::Utils::Crypto::CreateAES_KeyWrapImplementa
902902
return GetAES_KeyWrapFactory()->CreateImplementation(key);
903903
}
904904

905-
#ifdef _WIN32
905+
#ifdef _MSC_VER
906906
#pragma warning(pop)
907907
#endif
908908

tests/aws-cpp-sdk-s3-integration-tests/BucketAndObjectOperationTest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#include <fstream>
5050
#include <thread>
5151

52-
#ifdef _WIN32
52+
#ifdef _MSC_VER
5353
#pragma warning(disable: 4127)
5454
#ifdef GetObject
5555
#undef GetObject

tests/testing-resources/include/aws/testing/AwsProtocolTestHelpers.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#pragma once
77

88
#include <aws/testing/Testing_EXPORTS.h>
9-
#include <aws/testing/AwsCppSdkGTestSuite.h>s
9+
#include <aws/testing/AwsCppSdkGTestSuite.h>
1010
#include <aws/testing/AwsTestHelpers.h>
1111

1212

tests/testing-resources/source/platform/windows/PlatformTesting.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
#include <aws/testing/platform/PlatformTesting.h>
77

8+
#ifdef _MSC_VER
89
#pragma warning(disable: 4996)
10+
#endif
911
#include <windows.h>
1012
#include <aws/core/utils/memory/stl/AWSStringStream.h>
1113

0 commit comments

Comments
 (0)