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


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 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)
{
}

  • 6
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值