如何在 iOS 中的 .c 文件中使用 Grand Central Dispatch
我在 iOS 项目中有一些 C 代码,我想使用 GCD 对其进行优化。目前,只有将 C 文件更改为 Objective-C 文件并导入 Foundation 框架,我才能编译代码。我必须在 C 文件中包含哪些内容才能访问 GCD?
我已经尝试过:
#include <dispatch/dispatch.h>
但这似乎不起作用,它总是抱怨具有 ^ 字符的代码块
I have some C code in an iOS project that I would like to optimize using GCD. Currently I can only get my code to compile if change my C file to an Objective-C file and import the Foundation framework. What do I have to include in my C file to get access to GCD?
I've tried:
#include <dispatch/dispatch.h>
but that doesn't seem to work it always complains about code blocks having the ^ character
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要告诉编译器使用
-fblocks
标志启用块。您还需要使用能够理解块的编译器(Clang 就是其中之一)。You'll need to tell the compiler to enable Blocks with the
-fblocks
flag. You'll also need to use a compiler that understands blocks (Clang, for one).您可能需要;
但这不是我自己做过的事情,所以这里可能是错误的。
You might need to;
But it's not something I've done myself so could be wrong here.