我正在使用覆盆子pi(ARM)交叉编译(主机:x86 linux)
arm-bcm2708hardfp-linux-gnueabi-g++
Run Code Online (Sandbox Code Playgroud)
当我选择g ++时,一切都很好并且编译.但是当交叉编译时,我得到:
error: 'close' was not declared in this scope
Run Code Online (Sandbox Code Playgroud)
这是简化的源代码
#include <iostream>
#include <fcntl.h>
using namespace std;
int fd;
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
close(fd);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
任何的想法?我忘了包括smth吗?我使用eclipse作为IDE.
Quu*_*one 33
我相信它就像这样简单:close声明<unistd.h>,而不是<fcntl.h>.要找出哪个头文件声明符号,您应该首先检查手册页.
#include <iostream>
#include <unistd.h> // problem solved! it compiles!
using namespace std;
int fd;
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
close(fd); // but explicitly closing fd 0 (stdin) is not a good idea anyway
return 0;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
27863 次 |
| 最近记录: |