1
0
mirror of https://github.com/minio/minio-cpp.git synced 2025-07-31 16:24:23 +03:00

Fixed a GetObject() function colliding with WinAPI macro (#139)

This commit is contained in:
Petr Kobalicek
2024-07-03 11:08:48 +02:00
committed by GitHub
parent 0352bb3a5b
commit cd4ef14955
2 changed files with 34 additions and 0 deletions

View File

@ -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(
@ -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