linux找不到sys io.h,osx sys/io.h not found

问题

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?

Any help would be really appreciated!

Thanks!

回答1:

Include instead.

or why not both?

#ifdef __APPLE__

#include

#else

#include

#endif

In case of Apple OS (OSX/iOS) the code will know compile with

回答2:

What bibor has written is perfect. Though my file looks something like this and works well.

#ifdef __linux

#include

#elseif __apple

#include

回答3:

$ 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.

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.

回答4:

You can manually add it to your project, and it should compile.

https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6/+/master/sysroot/usr/include/sys/io.h

Edit: You need features.h as well

https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6/+/master/sysroot/usr/include/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...

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));

}

来源:https://stackoverflow.com/questions/2762010/osx-sys-io-h-not-found

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值