Fox, Michael
2014-09-08 01:03:26 UTC
How can FFI work across platforms unless you compile against the specific platform?s headers?
Sometimes a common header defines the same-named structure, type or macro differently depending on your platform.
For example, here?s a definition from termios.h on OSX:
#define CSIZE 0x00000300 /* character size mask */
And here?s the same one on some old Linux:
#define CSIZE 0000060
So, you can?t just take one of them and define it like:
pub static CSIZE: ulong_t = 0x300;
I don?t see how it can work unless you embed a C compiler which reads and uses the actual platform?s headers.
Sometimes a common header defines the same-named structure, type or macro differently depending on your platform.
For example, here?s a definition from termios.h on OSX:
#define CSIZE 0x00000300 /* character size mask */
And here?s the same one on some old Linux:
#define CSIZE 0000060
So, you can?t just take one of them and define it like:
pub static CSIZE: ulong_t = 0x300;
I don?t see how it can work unless you embed a C compiler which reads and uses the actual platform?s headers.