Block_copy 丢失

发布于 2024-11-16 20:58:39 字数 507 浏览 6 评论 0原文

我有一个 Xcode 项目,其中包含 OpenFeint 作为依赖项。 OpenFeint 有一个类对 Block_copy() 进行了两次调用,并对 Block_release() 进行了一次调用。一切都很顺利(例如,我多次构建并运行该项目,没有发生任何事件),直到编译器突然开始抱怨这些函数不存在。这实际上是在两个构建之间发生的,中间没有对源代码进行任何更改。

我不知道这些函数可能去了哪里,但我尝试通过提供一些占位符函数原型来解决它,如下所示:

extern void* Block_copy(const void *aBlock);
extern void Block_release(const void *aBlock);

我不确定这些是否是正确的签名(有关此主题的文档很少,充其量),但这是我能找到的最接近的。遗憾的是,这只会导致链接器而不是编译器抱怨。

那么有什么想法吗?我的整个开发环境都搞砸了吗?如果没有,我该如何让它再次工作?

I have an Xcode project which includes OpenFeint as a dependency. OpenFeint has one class that makes two calls to Block_copy() and one call to Block_release(). All was well (as in, I built and ran the project a number of times without incident) until suddenly the compiler started complaining that these functions don't exist. The thing literally broke in between two builds, with no changes to the source code in between.

I have no idea where these functions could have gone, but I've attempted to work around it by providing some placeholder function prototypes, like so:

extern void* Block_copy(const void *aBlock);
extern void Block_release(const void *aBlock);

I'm not sure if those are the correct signatures (the documentation on this topic is sparse, at best), but it's the closest I've been able to find. Sadly, this just causes the linker to complain instead of the compiler.

So any ideas? Is my whole development environment screwed? If not, how do I get it working again?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

对你的占有欲 2024-11-23 20:58:40

Block_copy的实际定义在
/Developer/SDKs/MacOSX10.6.sdk/usr/include/Block.h
并读取
#define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__)))
和 _Block_copy 在同一文件中定义为
BLOCK_EXPORT void *_Block_copy(const void *aBlock);

提供您自己的定义对 Xcode 没有帮助。你的 XCode 目标改变了吗?

The actual definition of Block_copy is in
/Developer/SDKs/MacOSX10.6.sdk/usr/include/Block.h
and reads
#define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__)))
and _Block_copy is defined in the same file by
BLOCK_EXPORT void *_Block_copy(const void *aBlock);

Providing your own definition will not help Xcode. Has your target in XCode changed ?

勿挽旧人 2024-11-23 20:58:40

临时解决方法是将“Block.h”的全部内容内联到 OpenFeint 源文件中。奇怪的是,尝试 #include#import 文件不起作用,这可能是问题的全部。

无论如何,该文件应存在于 /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator[VERSION].sdk/usr/include/Block.h 中,内容应为:

#ifndef _Block_H_
#define _Block_H_

#if !defined(BLOCK_EXPORT)
#   if defined(__cplusplus)
#       define BLOCK_EXPORT extern "C" 
#   else
#       define BLOCK_EXPORT extern
#   endif
#endif

#include <Availability.h>
#include <TargetConditionals.h>

#if __cplusplus
extern "C" {
#endif

    // Create a heap based copy of a Block or simply add a reference to an existing one.
    // This must be paired with Block_release to recover memory, even when running
    // under Objective-C Garbage Collection.
    BLOCK_EXPORT void *_Block_copy(const void *aBlock)
    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);

    // Lose the reference, and if heap based and last reference, recover the memory
    BLOCK_EXPORT void _Block_release(const void *aBlock)
    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);


    // Used by the compiler. Do not call this function yourself.
    BLOCK_EXPORT void _Block_object_assign(void *, const void *, const int)
    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);

    // Used by the compiler. Do not call this function yourself.
    BLOCK_EXPORT void _Block_object_dispose(const void *, const int)
    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);

    // Used by the compiler. Do not use these variables yourself.
    BLOCK_EXPORT void * _NSConcreteGlobalBlock[32]
    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
    BLOCK_EXPORT void * _NSConcreteStackBlock[32]
    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);


#if __cplusplus
}
#endif

// Type correct macros

#define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__)))
#define Block_release(...) _Block_release((const void *)(__VA_ARGS__))


#endif

A temporary workaround is to inline the entire contents of 'Block.h' in the OpenFeint source file. Strangely, trying to #include or #import the file does not work, which may be the whole of the problem.

In any case, this file should exist at /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator[VERSION].sdk/usr/include/Block.h, and the contents should be:

#ifndef _Block_H_
#define _Block_H_

#if !defined(BLOCK_EXPORT)
#   if defined(__cplusplus)
#       define BLOCK_EXPORT extern "C" 
#   else
#       define BLOCK_EXPORT extern
#   endif
#endif

#include <Availability.h>
#include <TargetConditionals.h>

#if __cplusplus
extern "C" {
#endif

    // Create a heap based copy of a Block or simply add a reference to an existing one.
    // This must be paired with Block_release to recover memory, even when running
    // under Objective-C Garbage Collection.
    BLOCK_EXPORT void *_Block_copy(const void *aBlock)
    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);

    // Lose the reference, and if heap based and last reference, recover the memory
    BLOCK_EXPORT void _Block_release(const void *aBlock)
    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);


    // Used by the compiler. Do not call this function yourself.
    BLOCK_EXPORT void _Block_object_assign(void *, const void *, const int)
    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);

    // Used by the compiler. Do not call this function yourself.
    BLOCK_EXPORT void _Block_object_dispose(const void *, const int)
    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);

    // Used by the compiler. Do not use these variables yourself.
    BLOCK_EXPORT void * _NSConcreteGlobalBlock[32]
    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
    BLOCK_EXPORT void * _NSConcreteStackBlock[32]
    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);


#if __cplusplus
}
#endif

// Type correct macros

#define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__)))
#define Block_release(...) _Block_release((const void *)(__VA_ARGS__))


#endif
萌辣 2024-11-23 20:58:39

你是否切换了 XCode 或者 iOS(暗示最近为开发人员发布了一些东西)。如果您意外切换到 ARC,这些功能可能不再存在(ARC 不受 NDA 保护,因为它已经存在并且是开源的)。

Did you switch XCode or perhaps iOS (hinting at something recently released for developers). It might be that, if you switched to ARC accidentally, those functions may no longer exist (ARC isn't under NDA since it already existed and is open source).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文