ios - XCode iOS operator 新的自定义实现

标签 ios exception xcode4.2 new-operator

XCode 对我的全局运算符 new 的实现发出警告:

void *operator new(size_t blocksize);

它说:“operator new”缺少异常规范“throw(std::bad_alloc)”

但我的实现并不打算抛出任何异常,我宁愿将其声明为

void *operator new(size_t blocksize) throw();

但是,后一种实现会导致错误:

声明中的异常规范与之前的声明不匹配

所以,问题是:我是否真的被迫(让 XCode 编译器平静下来)将自定义“operator new”声明为 throw(std::bad_alloc),即使它不会抛出任何异常?

最佳答案

So, the question is: am I really forced (to calm down XCode compiler) to declare a custom 'operator new' as throw(std::bad_alloc) even if it wont throw any exception?

是的,你这样做:

http://developer.apple.com/library/mac/#technotes/tn2185/_index.html

For complete control and portability, if you replace any of these signatures, you should replace all of them. However the default implementation of the array forms simply forward to the non-array forms. If you only replace the four non-array forms, expect the default array forms to forward to your replacements.

关于ios - XCode iOS operator 新的自定义实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8519905/

相关文章:

iphone - 如何以编程方式检查 Mobclix 广告是否正在运行?

javascript - 安卓/IOS 浏览器。防止默认键盘显示在字段焦点上 (Javascript)

ios - 在 IOS 应用程序中使用 FFMPEG 的可靠性?

ios - Realm 迁移问题。如何更新应该在其中的数据

ios - 从 ViewController 调用 UIView 方法

objective-c - 通过 Storyboard 加载时如何初始化 View ?

c# - 隐式运算符应该处理 null 吗?

sql - 如何处理 Oracle SQL 中的无效日期

perl - 如何为模具处理程序提供更多上下文?

objective-c - ARC 是否足够聪明以释放父类(super class)中定义的 subview ?