您当前的位置: 首页 >  c++

柳鲲鹏

暂无认证

  • 0浏览

    0关注

    4642博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

C++的操作符delete很特殊,跟new不对称

柳鲲鹏 发布时间:2019-01-11 17:44:05 ,浏览量:0

代码声明如下:

#if __cplusplus & MEMORY_TRACE_FLAG & MEMORY_TRACE_OPERATOR
void* operator new(      long unsigned int nSize, const char* pFile, const char* pFunction, const int nLine);
void* operator new [](   long unsigned int nSize, const char* pFile, const char* pFunction, const int nLine);
void  operator delete(   void* p,                 const char* pFile, const char* pFunction, const int nLine);
void  operator delete [](void* p,                 const char* pFile, const char* pFunction, const int nLine);

#endif

宏定义(其他的头文件):

#define new       new(   __FILE__, __FUNCTION__, __LINE__)
#define delete    delete(__FILE__, __FUNCTION__, __LINE__)

奇怪的事情出现了:

new可以正确执行.

delete根本就编译不过.这是为什么?

错误是:

error: type ‘int’ argument given to ‘delete’, expected pointer
 #define delete    delete(__FILE__, __FUNCTION__, __LINE__)
                                                          ^
../gh-manager/gh_camera.h:56:17: note: in expansion of macro ‘delete’
                 delete pConfigure;

 

关注
打赏
1665724893
查看更多评论
立即登录/注册

微信扫码登录

0.0660s