Skip to content
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

[DO NOT MERGE] test issue 134 #141

Closed
Closed
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
29 changes: 29 additions & 0 deletions include/miniocpp/baseclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
#include "response.h"
#include "utils.h"

#if defined(_WIN32) && defined(GetObject)
#pragma push_macro("GetObject")
#undef GetObject
#define MINIO_CPP_GET_OBJECT_DEFINED
#endif

namespace minio::s3 {

utils::Multimap GetCommonListObjectsQueryParams(
Expand Down Expand Up @@ -150,8 +156,31 @@ class BaseClient {
StatObjectResponse StatObject(StatObjectArgs args);
UploadPartResponse UploadPart(UploadPartArgs args);
UploadPartCopyResponse UploadPartCopy(UploadPartCopyArgs args);

// Windows API fix:
//
// Windows API headers define `GetObject()` as a macro that expands to either
// `GetObjectA()` or `GetObjectW()`. This means that users can get link errors
// in case that one compilation unit used `GetObject()` macro and other
// didn't. This fixes the issue by providing both functions `GetObject()` can
// expand to as inline wrappers.
#if defined(_WIN32)
inline GetObjectResponse GetObjectA(const GetObjectArgs& args) {
return GetObject(args);
}

inline GetObjectResponse GetObjectW(const GetObjectArgs& args) {
return GetObject(args);
}
#endif // _WIN32

}; // class BaseClient

} // namespace minio::s3

#if defined(_WIN32) && defined(MINIO_CPP_GET_OBJECT_DEFINED)
#undef MINIO_CPP_GET_OBJECT_DEFINED
#pragma pop_macro("GetObject")
#endif

#endif // MINIO_CPP_BASECLIENT_H_INCLUDED
5 changes: 5 additions & 0 deletions src/baseclient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
#include "miniocpp/types.h"
#include "miniocpp/utils.h"

// We want exactly `minio::s3::BaseClient::GetObject()` symbol and nothing else.
#if defined(GetObject)
#undef GetObject
#endif

namespace minio::s3 {

utils::Multimap GetCommonListObjectsQueryParams(
Expand Down
5 changes: 5 additions & 0 deletions tests/tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
//
// SPDX-License-Identifier: Apache-2.0

#ifdef _WIN32
#define UNICODE
#include <windows.h> // To Test https://github.com/minio/minio-cpp/issues/134
#endif

#include <miniocpp/args.h>
#include <miniocpp/client.h>
#include <miniocpp/http.h>
Expand Down
Loading