macos 找不到 osx sys/io.h
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2762010/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
osx sys/io.h not found
提问by ioh
I'd like to compile a c programm developed for linux using cc under os x. It includes the header sys/io.h. When compiling I get the error that this file could not be found? Isn't there any sys/io.h header file under os x?
我想在os x下使用cc编译为linux开发的ac程序。它包括头文件 sys/io.h。编译时出现找不到此文件的错误?os x下没有sys/io.h头文件吗?
Any help would be really appreciated!
任何帮助将非常感激!
Thanks!
谢谢!
回答by bibor
Include <sys/uio.h>
instead.
<sys/uio.h>
改为包括。
or why not both?
或者为什么不是两者?
#ifdef __APPLE__
#include <sys/uio.h>
#else
#include <sys/io.h>
#endif
In case of Apple OS (OSX/iOS) the code will know compile with <sys/uio.h>
在 Apple OS (OSX/iOS) 的情况下,代码将知道编译 <sys/uio.h>
回答by niknak
What bibor has written is perfect. Though my file looks something like this and works well.
bibor 写的很完美。虽然我的文件看起来像这样并且运行良好。
#ifdef __linux
#include <io.h>
#elseif __apple
#include<uio.h>
回答by WhirlWind
$ ls /usr/include/sys/io.h
ls: /usr/include/sys/io.h: No such file or directory
It doesn't look like it. You may have to do some porting.
它看起来不像。您可能需要进行一些移植。
Linux has this header file. It looks like it has to do with low level port input and output.
Linux 有这个头文件。看起来它与低电平端口输入和输出有关。
In general, things in /usr/include/sys are going to be operating-system specific, so you'll have to port to a new architecture if it's not already ported.
通常,/usr/include/sys 中的内容将是特定于操作系统的,因此如果尚未移植,则必须移植到新架构。
回答by scubasteve623
You can manually add it to your project, and it should compile.
您可以手动将它添加到您的项目中,它应该会编译。
Edit: You need features.h as well
编辑:您还需要 features.h
Finally got cursor support in my kernel, although the functions in io.h weren't working for me. They compiled fine, and may help someone else. This is the code I'm going forward with...
终于在我的内核中获得了游标支持,尽管 io.h 中的函数对我不起作用。他们编译得很好,可能会帮助别人。这是我要前进的代码......
static inline void outb(unsigned short port, unsigned char value)
{
__asm__ __volatile__ ("outb %1, %0" : : "dN" (port), "a" (value));
}
static inline unsigned char inb(unsigned short port)
{
unsigned char value;
__asm__ __volatile__ ("inb %1, %0" : "=a"(value) : "Nd"(port));
return value;
}
void update_cursor(int row, int col)
{
unsigned short position=(row*80) + col;
// cursor LOW port to vga INDEX register
outb(0x3D4, 0x0F);
outb(0x3D5, (unsigned char)(position&0xFF));
// cursor HIGH port to vga INDEX register
outb(0x3D4, 0x0E);
outb(0x3D5, (unsigned char )((position>>8)&0xFF));
}