gpt4 book ai didi

c++ - 包括 windows.storage.streams.h

转载 作者:行者123 更新时间:2023-11-30 01:22:49 26 4
gpt4 key购买 nike

我正在尝试将类 NativeBuffer 从 this answer 放入但是当 windows.storage.streams.h 我有很多错误,比如:

Error   1   error C2872: 'AsyncStatus' : ambiguous symbol   c:\program files (x86)\windows phone kits\8.0\include\abi\asyncinfo.h   75
Error 2 error C2872: 'AsyncStatus' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\asyncinfo.h 76
Error 3 error C2872: 'AsyncStatus' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\asyncinfo.h 77
Error 4 error C2872: 'AsyncStatus' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\asyncinfo.h 78
Error 5 error C2371: 'IAsyncInfo' : redefinition; different basic types c:\program files (x86)\windows phone kits\8.0\include\abi\asyncinfo.h 108
Error 6 error C2872: 'AsyncStatus' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\asyncinfo.h 115
Error 7 error C2872: 'EventRegistrationToken' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\windows.foundation.collections.h 1185
Error 8 error C2872: 'EventRegistrationToken' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\windows.foundation.collections.h 1186
Error 9 error C2872: 'EventRegistrationToken' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\windows.foundation.collections.h 1224
Error 10 error C2872: 'EventRegistrationToken' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\windows.foundation.collections.h 1225
Error 11 error C3431: 'PropertyType' : a scoped enumeration cannot be redeclared as an unscoped enumeration c:\program files (x86)\windows phone kits\8.0\include\abi\windows.foundation.h 3984
Error 12 error C2371: 'ABI::Windows::Foundation::PropertyType' : redefinition; different basic types c:\program files (x86)\windows phone kits\8.0\include\abi\windows.foundation.h 15298
Error 13 error C2872: 'EventRegistrationToken' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\windows.storage.search.h 4005
Error 14 error C2872: 'EventRegistrationToken' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\windows.storage.search.h 4008
Error 15 error C2872: 'EventRegistrationToken' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\windows.storage.search.h 4012
Error 16 error C2872: 'EventRegistrationToken' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\windows.storage.search.h 4015
Error 17 error C2872: 'EventRegistrationToken' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\windows.storage.h 10488
Error 18 error C2872: 'EventRegistrationToken' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\windows.storage.h 10491
Error 19 error C2039: 'RuntimeClass' : is not a member of 'Microsoft::WRL' c:\users\sergey.fedortsov\documents\socialholdem\prj.ipoker\wp8\shared\platform\wp\nativebuffer.h 12
Error 20 error C2504: 'RuntimeClass' : base class undefined c:\users\sergey.fedortsov\documents\socialholdem\prj.ipoker\wp8\shared\platform\wp\nativebuffer.h 12
Error 21 error C2143: syntax error : missing ',' before '<' c:\users\sergey.fedortsov\documents\socialholdem\prj.ipoker\wp8\shared\platform\wp\nativebuffer.h 12
Error 22 error C2039: 'RuntimeClassFlags' : is not a member of 'Microsoft::WRL' c:\users\sergey.fedortsov\documents\socialholdem\prj.ipoker\wp8\shared\platform\wp\nativebuffer.h 13
Error 23 error C3083: 'RuntimeClassType': the symbol to the left of a '::' must be a type c:\users\sergey.fedortsov\documents\socialholdem\prj.ipoker\wp8\shared\platform\wp\nativebuffer.h 13
Error 24 error C2039: 'WinRtClassicComMix' : is not a member of 'Microsoft::WRL' c:\users\sergey.fedortsov\documents\socialholdem\prj.ipoker\wp8\shared\platform\wp\nativebuffer.h 13
Error 25 error C2039: 'FtmBase' : is not a member of 'Microsoft::WRL' c:\users\sergey.fedortsov\documents\socialholdem\prj.ipoker\wp8\shared\platform\wp\nativebuffer.h 16

我的代码:

    #ifndef NATIVE_BUFFER_H
#define NATIVE_BUFFER_H


#include <robuffer.h>
#include <wrl.h>
#include <wrl/implements.h>
#include <wrl\client.h>
#include <windows.storage.streams.h>


/// <summary>
/// The purpose of this class is to transform byte buffers into an IBuffer
/// </summary>
class NativeBuffer : public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags< Microsoft::WRL::RuntimeClassType::WinRtClassicComMix >,
ABI::Windows::Storage::Streams::IBuffer,
Windows::Storage::Streams::IBufferByteAccess,
Microsoft::WRL::FtmBase>
{

public:
virtual ~NativeBuffer()
{
if (m_pBuffer && m_bIsOwner)
{
delete[] m_pBuffer;
m_pBuffer = NULL;
}
}

STDMETHODIMP RuntimeClassInitialize(UINT totalSize)
{
m_uLength = totalSize;
m_uFullSize = totalSize;
m_pBuffer = new BYTE[totalSize];
m_bIsOwner = TRUE;
return S_OK;
}

STDMETHODIMP RuntimeClassInitialize(BYTE* pBuffer, UINT totalSize, BOOL fTakeOwnershipOfPassedInBuffer)
{
m_uLength = totalSize;
m_uFullSize = totalSize;
m_pBuffer = pBuffer;
m_bIsOwner = fTakeOwnershipOfPassedInBuffer;
return S_OK;
}

STDMETHODIMP Buffer( BYTE **value)
{
*value = m_pBuffer;
return S_OK;
}

STDMETHODIMP get_Capacity(UINT32 *value)
{
*value = m_uFullSize;
return S_OK;
}

STDMETHODIMP get_Length(UINT32 *value)
{
*value = m_uLength;
return S_OK;
}

STDMETHODIMP put_Length(UINT32 value)
{
if(value > m_uFullSize)
{
return E_INVALIDARG;
}
m_uLength = value;
return S_OK;
}

static Windows::Storage::Streams::IBuffer^ GetIBufferFromNativeBuffer(Microsoft::WRL::ComPtr<NativeBuffer> spNativeBuffer)
{
auto iinspectable = reinterpret_cast<IInspectable*>(spNativeBuffer.Get());
return reinterpret_cast<Windows::Storage::Streams::IBuffer^>(iinspectable);
}
static BYTE* GetBytesFromIBuffer(Windows::Storage::Streams::IBuffer^ buffer)
{
auto iinspectable = (IInspectable*)reinterpret_cast<IInspectable*>(buffer);
Microsoft::WRL::ComPtr<Windows::Storage::Streams::IBufferByteAccess> spBuffAccess;
HRESULT hr = iinspectable->QueryInterface(__uuidof(Windows::Storage::Streams::IBufferByteAccess), (void **)&spBuffAccess);
UCHAR * pReadBuffer;
spBuffAccess->Buffer(&pReadBuffer);
return pReadBuffer;
}
private:
UINT32 m_uLength;
UINT32 m_uFullSize;
BYTE* m_pBuffer;
BOOL m_bIsOwner;
};


#endif

这可能是什么原因?

最佳答案

最可能的原因是您在头文件中使用命名空间!

例如。

// Header
using namespace System;
using namespace std;

// Your class declaration

从 header 中删除所有命名空间。使用显式类包含,例如

using System::Int32;
using std::vector;

由于您将此 header 包含在其他 header 中,然后包含标准 header - 所有内容都进入(或被处理)全局命名空间。它引起了歧义。您不能更改标准 header (通过前缀 :: 或其他命名空间)。

关于c++ - 包括 windows.storage.streams.h,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15767146/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com