Supporting linux/types.h OSX
c++, macos
Solution
Obviously a Linux-specific header file is not going to be present under MacOS/X, which is not Linux-based.
The easiest work-around for the problem would be to go through your program and replace all the instances of
#include "linux/types.h"
with this:
#include "my_linux_types.h"
... and write a new header file named my_linux_types.h and add it to your project; it would look something like this:
#ifndef my_linux_types_h
#define my_linux_types_h
#ifdef __linux__
# include "linux/types.h"
#else
# include <stdint.h>
typedef int32_t __s32;
typedef uint8_t __u8;
typedef uint16_t __u16;
[... and so on for whatever other types your program uses ...]
#endif
#endif
Problem
I am trying to cross compile an application using OSX. However, when I compile I get the following... ``` fatal error: 'linux/types.h' file not found ``` When I change to sys/types.h and now I get... ``` error: unknown type name '__s32' unknown type name '__u8' unknown type name '__u16' etc ``` Can someone help me with how to handle this?