- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
编译 serna-free 包时出现以下错误:
build/buildd-serna-free_4.3.0.20110221-2-i386-pAsDoD/serna-free-4.3.0.20110221/
sfworks/common/RefCntStorage.h:76:10:
error: non-placement deallocation function 'static void
StringPrivate::RefCntData<E>::operator
delete(void*,StringPrivate::size_type) [with E = QChar,
StringPrivate::size_type = unsigned int]'
/build/buildd-serna-free_4.3.0.20110221-2-i386-pAsDoD/serna-free-4.3.0.20110221/
sfworks/common/RefCntStorage.h:135:9:
error: selected for placement delete
代码如下:
void operator delete(void* p, size_type)
{
::operator delete(p);
}
最佳答案
我认为问题来自规范中的这个措辞:
If class T does not declare such an operator delete but does declare a member deallocation function named operator delete with exactly two parameters, the second of which has type std::size_t (18.1), then this function is a usual deallocation function
这意味着如果您尝试声明一对 operator new
和 operator delete
并将 size_t
作为第二个参数,则编译器会认为您的 operator delete
具有以下签名:
void operator delete (void* memory, size_t arg)
是标准(非放置)释放器,而不是应该匹配 operator new(void*, size_t)
的放置释放器。
奇怪的是,规范中没有任何地方说这会导致编译器错误。事实上,规范只是说,如果你有这个错误,那么如果自定义 new
抛出异常,那么内存就不会被清理。如果有人知道为什么 g++
将此报告为错误,我很想知道为什么(尤其是 如果我错了并且这确实应该是非法的)。
编辑:啊!问题似乎来自 C++0x。根据新标准的最新草案,§3.5.4/20:
If the lookup finds the two-parameter form of a usual deallocation function (3.7.4.2) and that function, considered as a placement deallocation function, would have been selected as a match for the allocation function, the program is ill-formed.
它特别列出了这样做会导致破损的示例。这是 C++0x 中的新功能这一事实可以解释为什么该错误仅在最新版本的 g++
中出现。
关于c++ - 错误 "non-placement deallocation function"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5367674/
演讲的主题是 Objective-c 中的类和对象。我无法理解 [super dealloc] 的概念。我们有一些类 myClass,它继承自 NSObject。它有一些方法并从父类继承其他方法。所以
对于 ARC,有时我仍然需要编写一个 -dealloc 方法来进行一些清理。在极少数情况下,我需要引用实例的属性才能正确进行清理。例如从 NSNotificationCenter 中注销给定的发送者对
如果我有一个由 View Controller 控制的 View 堆栈,并且当我从 View 堆栈中弹出 View 时调用了 View 的 dealloc(包含 [super dealloc] )方法
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 9 年前。 Improve
当我的应用程序开始在我的自定义注释方法中崩溃时,我了解到我的内存有问题。我确信管理 map 的 viewcontroller 100% 应该已经从 View 堆栈中弹出。 这里是注释的代码,TaxiA
我刚刚一直在阅读有关如何正确地在 init 方法中失败的信息,并且文档似乎彼此不同意。一个建议抛出异常,而其他建议清理并返回 nil。当前的最佳做法是什么? 最佳答案 我相信普遍接受的做法是在失败时返
这是我的情况。这很复杂,所以请耐心等待。 我有一个 View 类,我们称它为 MyView。它创建一个加载指示器 subview ,然后启动将加载数据的后台操作。它还创建了一个 block ,后台队列
我正在设置 AMScrollingNavbar在 swift 。当我尝试转换时 - (void)dealloc { [self stopFollowingScrollView]; } 到 func
我正在尝试执行以下操作: 获得类'dealloc IMP 向所述类中注入(inject)一个自定义 IMP,它基本上调用原始的 dealloc IMP 当所述类的一个实例被释放时,两个 IMP 都应该
在我的一个 View Controller 中,它将自身添加为 UITextViewTextDidEndEditingNotification 通知的观察者,如下所示 [[NSNotification
我正在初始化一个对象,然后内联配置它。但是,不是在配置前一个实例(如果之前已分配)之前将其释放(在紧随其后的行中),而是推迟释放。因此,我对它所做的所有配置最终都成为一个已释放的对象 - 这当然不是我
是否需要将所有声明为IBOutlet的带有retain修饰符的@property设置为nil - (void)dealloc 方法?如果我不这样做,内存会被消耗/浪费吗? 假设自动引用计数关闭。 最佳
这是我在应用程序中切换 View 的方式: CGRect frame = self.view.frame; frame.origin.x = CGRectGetMaxX(frame);
假设有一个带有两个选项卡 A 和 B 的选项卡栏 Controller ,其中 A 是导航 Controller 。 当用户在A中时,他可以推送A1,然后推送A2,它们都是 View Controll
我有一个加载两个 View Controller 的 Root View 。例如:FirstVC、SecondVC。 当应用程序启动时,我将 FirstVC 显示为 Root View Control
我有一个基于导航的应用程序,可以在一些 ViewController 之间切换。如果我按下“goHome”按钮,方法 popViewControllerAnimated: 被调用,然后我返回到主屏幕。
我正在尝试调试为什么我的 dealloc 覆盖没有在我的一个 View Controller 上被调用。 我有一个通过 Storyboard设置的 View Controller 。我已经重写了所有
对于我的 iOS 7 应用,只想确认: dealloc 是否仍会被调用? 与是否开启ARC有关系吗? 最佳答案 是的,无论您是否使用 ARC,dealloc 都会在对象被释放时调用。 但是请注意,当您
我很难适应 C++ 处理动态和自动内存的方式。 我的问题: 指向自动分配实例的指针是否可以保留该实例解除分配,即使实例化范围已离开? 在this帖子我读到所有指向 dealloc 内存的指针都是无效的
我有三个 UIViewControllers,每当我关闭它们时,它们的所有 dealloc 方法都会被调用。这正是我想要发生的事情,这样内存就不会膨胀。 但是,当我运行配置文件来测试内存使用情况和一些
我是一名优秀的程序员,十分优秀!