VS2017编译DirectX11的Effect框架时,出现C2323错误

来源:互联网 发布:生活中的帅哥知乎 编辑:程序博客网 时间:2024/05/29 13:21

d3dxGlobal.h中下列位置出错:

// Custom allocator that uses CDataBlockStore// The trick is that we never free, so we don't have to keep as much state around// Use PRIVATENEW in CEffectLoaderstatic void* __cdecl operator new(size_t s, CDataBlockStore &pAllocator){    D3DXASSERT(s <= 0xffffffff);    return pAllocator.Allocate((UINT)s);}static void __cdecl operator delete(void* p, CDataBlockStore &pAllocator){}

MSDN的解释:

这里写图片描述


与VS的说明是差不多的,是因为新版的VS禁止全局static重载new/delete,只要把static [inline]去掉就可以了;

但是在Effect框架里,new 和delete都是在头文件中定义,是定义不是声明,改完之后框架是能编译通过,但是使用框架的时候会出现链接错误,需要把定义改为声明,然后在Cpp文件中定义:

//**************d3dxGlobal.h*****************// Custom allocator that uses CDataBlockStore// The trick is that we never free, so we don't have to keep as much state around// Use PRIVATENEW in CEffectLoader//static    extern void* __cdecl operator new(size_t s, CDataBlockStore &pAllocator);//static    extern void __cdecl operator delete(void* p, CDataBlockStore &pAllocator);
//**************d3dxGlobal.cpp***********************// Custom allocator that uses CDataBlockStore// The trick is that we never free, so we don't have to keep as much state around// Use PRIVATENEW in CEffectLoader//void* __cdecl operator new(size_t s, CDataBlockStore &pAllocator){    D3DXASSERT(s <= 0xffffffff);    return pAllocator.Allocate((UINT)s);}//void __cdecl operator delete(void* p, CDataBlockStore &pAllocator){}

阅读全文
0 0
原创粉丝点击