你能在iPhone上使用C open(const char* name, int flag)函数吗?

发布于 2024-12-25 19:02:56 字数 120 浏览 4 评论 0原文

我正在尝试移植一个库以在 iPhone 上运行,该库利用内存映射和许多其他东西。我注意到还缺少一堆 #defines (O_RDONLY),它们应该在 中定义。

I am trying to port a library to run on the iPhone which makes use of memory mapping and a bunch of other stuff. I noticed a bunch of #defines missing as well (O_RDONLY) which should be defined in <fcntl.h>.

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

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

发布评论

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

评论(3

椒妓 2025-01-01 19:02:56

您可以使用它,但默认情况下,fcntl.h 标头不包含在 Foundation 或 UIKit 框架中。要使用 open(2) 系统调用,只需在使用该标头的任何位置导入该标头(或将其添加到预编译的标头文件中)即可。

例如:

#import <fcntl.h>

// now you can use open or import your library header files

You can use it, but the fcntl.h header is not included in the Foundation or UIKit frameworks by default. To use the open(2) system call, simply import that header wherever you use it (or add it to your pre-compiled header file).

For example:

#import <fcntl.h>

// now you can use open or import your library header files
江挽川 2025-01-01 19:02:56

为什么不呢?它可能存在的唯一问题是苹果不接受它,因为他们扫描程序中的系统调用。但我相信开放系统调用就可以了。

Why not? The only problem that it might have is apple not accepting it, as they scan programs for system calls. But I believe an open system call is fine.

绝影如岚 2025-01-01 19:02:56

为我工作的代码:

#include <fcntl.h>

- (BOOL) openFile:(NSString *)filePath ......{
...
const char * filePathStr = [filePath UTF8String];
int fd = open(filePathStr, O_RDONLY);
...
}

worked code for me:

#include <fcntl.h>

- (BOOL) openFile:(NSString *)filePath ......{
...
const char * filePathStr = [filePath UTF8String];
int fd = open(filePathStr, O_RDONLY);
...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文