我可以在托管代码上使用 DEBUG_NEW 吗?
我可以使用:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
在托管代码中?
喜欢 C# 还是托管 C++?
can i use:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
in managed code?
like c# or managed c++?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这在 C++/CLI 中应该和在标准 C++ 中一样有效,也就是说,官方不允许重新定义诸如
new
之类的关键字,但大多数编译器都会允许您这样做。使用
__FILE__
没有问题,但如果您想从托管代码中使用它,您可能希望将其存储在托管字符串中。That should work in C++/CLI just as well as it does in standard C++, which is to say, it's officially not allowed to redefine keyword such as
new
, but most compilers will let you do it.With
__FILE__
there is no problem, although you probably want to store it in a managed string, if you want to use it from managed code.