Skip to content

Fixes for building with mingw #3319 #3315 #3385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@
"gnustl",
"libgnustl",
"Wmissing",
"Wmaybe",
"Wuninitialized",
// Android NDK
"JNIEXPORT",
"jint",
Expand Down
6 changes: 6 additions & 0 deletions cmake/compiler_settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ else()
set(COMPILER_CLANG 1)
else()
set(COMPILER_GCC 1)
if(MINGW)
set(COMPILER_MINGW 1)
endif()
endif()
set(USE_GCC_FLAGS 1)
endif()
Expand All @@ -34,6 +37,9 @@ endfunction()

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

if(NOT BUILD_SHARED_LIBS)
list(APPEND AWS_COMPILER_FLAGS "-fPIC")
Expand Down
10 changes: 10 additions & 0 deletions src/aws-cpp-sdk-core/include/aws/core/utils/event/EventHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
#include <aws/event-stream/event_stream.h>
#include <cassert>

#ifdef __MINGW32__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#pragma GCC diagnostic ignored "-Wuninitialized"
#endif

namespace Aws
{
namespace Utils
Expand Down Expand Up @@ -350,3 +356,7 @@ namespace Aws
}
}
}

#ifdef __MINGW32__
#pragma GCC diagnostic pop
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <aws/core/utils/ratelimiter/RateLimiterInterface.h>
#include <aws/core/utils/UnreferencedParam.h>

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

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

bool WinHttpSyncHttpClient::DoSendRequest(void* hHttpRequest) const
{
bool success = WinHttpSendRequest(hHttpRequest, NULL, NULL, 0, 0, 0, NULL) != 0;
bool success = WinHttpSendRequest(hHttpRequest, NULL, 0, NULL, 0, 0, 0) != 0;
if (!success)
{
AzWinHttpLogLastError("WinHttpSendRequest");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ bool WinINetSyncHttpClient::DoQueryHeaders(void* hHttpRequest, std::shared_ptr<H
char contentTypeStr[1024];
dwSize = sizeof(contentTypeStr);
HttpQueryInfoA(hHttpRequest, HTTP_QUERY_CONTENT_TYPE, &contentTypeStr, &dwSize, 0);
if (contentTypeStr[0] != NULL)
if (contentTypeStr[0])
{
response->SetContentType(contentTypeStr);
AWS_LOGSTREAM_DEBUG(GetLogTag(), "Received content type " << contentTypeStr);
Expand Down
7 changes: 6 additions & 1 deletion src/aws-cpp-sdk-core/source/platform/windows/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#include <iostream>
#include <Userenv.h>

#pragma warning( disable : 4996)
#ifdef _MSC_VER
#pragma warning(disable: 4996)
#endif

using namespace Aws::Utils;
namespace Aws
Expand Down Expand Up @@ -311,6 +313,9 @@ Aws::String CreateTempFilePath()
{
#ifdef _MSC_VER
#pragma warning(disable: 4996) // _CRT_SECURE_NO_WARNINGS
#elif !defined(L_tmpnam_s)
// Definition from the MSVC stdio.h
#define L_tmpnam_s (sizeof("\\") + 16)
#endif
char s_tempName[L_tmpnam_s+1];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

#include <iomanip>

#ifdef _MSC_VER
#pragma warning(disable: 4996)
#endif
#include <windows.h>
#include <stdio.h>
namespace Aws
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ std::shared_ptr<Aws::Utils::Crypto::HMAC> Aws::Utils::Crypto::CreateSha256HMACIm
return GetSha256HMACFactory()->CreateImplementation();
}

#ifdef _WIN32
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4702 )
#endif
Expand Down Expand Up @@ -902,7 +902,7 @@ std::shared_ptr<SymmetricCipher> Aws::Utils::Crypto::CreateAES_KeyWrapImplementa
return GetAES_KeyWrapFactory()->CreateImplementation(key);
}

#ifdef _WIN32
#ifdef _MSC_VER
#pragma warning(pop)
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include <fstream>
#include <thread>

#ifdef _WIN32
#ifdef _MSC_VER
#pragma warning(disable: 4127)
#ifdef GetObject
#undef GetObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#pragma once

#include <aws/testing/Testing_EXPORTS.h>
#include <aws/testing/AwsCppSdkGTestSuite.h>s
#include <aws/testing/AwsCppSdkGTestSuite.h>
#include <aws/testing/AwsTestHelpers.h>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

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

#ifdef _MSC_VER
#pragma warning(disable: 4996)
#endif
#include <windows.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>

Expand Down
Loading