Skip to content

Commit fe039d9

Browse files
author
Sergey Ryabinin
committed
Fixes for building with mingw #3319 #3315
1 parent 0505f3f commit fe039d9

File tree

9 files changed

+33
-8
lines changed

9 files changed

+33
-8
lines changed

cmake/compiler_settings.cmake

Lines changed: 6 additions & 0 deletions
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

Lines changed: 10 additions & 0 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ bool WinINetSyncHttpClient::DoQueryHeaders(void* hHttpRequest, std::shared_ptr<H
223223
char contentTypeStr[1024];
224224
dwSize = sizeof(contentTypeStr);
225225
HttpQueryInfoA(hHttpRequest, HTTP_QUERY_CONTENT_TYPE, &contentTypeStr, &dwSize, 0);
226-
if (contentTypeStr[0] != NULL)
226+
if (contentTypeStr[0])
227227
{
228228
response->SetContentType(contentTypeStr);
229229
AWS_LOGSTREAM_DEBUG(GetLogTag(), "Received content type " << contentTypeStr);

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

Lines changed: 6 additions & 1 deletion
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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/source/platform/windows/PlatformTesting.cpp

Lines changed: 2 additions & 0 deletions
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)