gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 11:18:07 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com