Osx sys / io.h not found

I would like to compile a c program developed for linux using cc under os x. It includes the sys / io.h header. When compiling, I get an error that this file cannot be found? Is there a header file under os x in ss / io.h?

Any help would be really appreciated!

Thank!

+3
source share
4 answers

Turn on <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 compilation with <sys/uio.h>

+8
source

What bibor wrote is perfect. Although my file looks something like this and works well.

#ifdef __linux

#include <io.h>

#elseif __apple

#include<uio.h>
+1
source
$ ls /usr/include/sys/io.h
ls: /usr/include/sys/io.h: No such file or directory

. , .

Linux . , .

, /usr/include/sys , , .

0

, .

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

: .h

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

, , 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));
}
0

Source: https://habr.com/ru/post/1743907/


All Articles