什么 C++我需要编译这个程序吗
当我尝试编译程序时,出现这些错误:
btio.c:19: error: ‘O_RDWR’ was not declared in this scope
btio.c:19: error: ‘open’ was not declared in this scope
btio.c: In function ‘short int create_tree()’:
btio.c:56: error: ‘creat’ was not declared in this scope
btio.c: In function ‘short int create_tree(int, int)’:
btio.c:71: error: ‘creat’ was not declared in this scope
我需要包含什么库来修复这些错误?
When I try to compile my program I get these errors:
btio.c:19: error: ‘O_RDWR’ was not declared in this scope
btio.c:19: error: ‘open’ was not declared in this scope
btio.c: In function ‘short int create_tree()’:
btio.c:56: error: ‘creat’ was not declared in this scope
btio.c: In function ‘short int create_tree(int, int)’:
btio.c:71: error: ‘creat’ was not declared in this scope
what library do I need to include to fix these errors?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您想要:
另外,请注意,正如 @R Samuel Klatchko 所写,这些不是“库”。
#include
的作用是将文件逐字插入到您的代码中。碰巧的是,标准头文件fcntl.h
将有这样一行:而
unistd.h
将有这样一行:换句话说,函数原型,它通知编译器认为该函数存在于某处,并且可以选择其参数的样子。
后面的链接步骤将在库中查找这些函数;这就是术语“库”的由来。最典型的是,这些函数将存在于名为
libc.so
的库中。您可以认为您的编译器代表您插入了标志-lc
(链接到libc
)。而且,这些不是“C++”,而是 POSIX。
You want:
Also, note that, as @R Samuel Klatchko writes, these are not "libraries". What
#include
does is inserts a file into your code verbatim. It just so happens that the standard headerfcntl.h
will have a line like:And
unistd.h
will have lines like:In other words, function prototypes, which informs the compiler that this function exists somewhere and optionally what its parameters look like.
The later linking step will then look for these functions in libraries; that is where the term "library" comes in. Most typically these functions will exist in a library called
libc.so
. You can think of your compiler inserting the flag-lc
(link tolibc
) on your behalf.Also, these are not "C++" but rather POSIX.
您尝试过
吗?搜索这些符号的任何组合都会产生......Have you tried
<fcntl.h>
? A search for any combination of those symbols would have yielded that...