IJsonValue.GetObject 方法与 windows.h 宏发生冲突

问题描述 投票:0回答:1

https://learn.microsoft.com/en-us/uwp/api/windows.data.json.ijsonvalue.getobject?view=winrt-22621

#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>
//in windows.h
//#define GetObject  GetObjectW

IJsonValue jsonValue = ...;
auto jsonObject = jsonValue.GetObject();

错误 C2039:“GetObjectW”:不是“winrt::Windows::Data::Json::IJsonValue”的成员

我尝试使用 `int max = (std::numeric_limits::max)();` 技巧,但仍然收到 `GetObjectW` 错误 ```` 自动 jsonObject = jsonValue.(winrt::Windows::Data::Json::IJsonValue::GetObject)(); ````

有什么想法吗?

c++ windows c++-winrt
1个回答
0
投票
#include <windows.h>
#ifdef GetObject
#undef GetObject
#endif
© www.soinside.com 2019 - 2024. All rights reserved.