OSX has no endian.h
NiklasRosenstein opened this issue · 5 comments
It seems OSX has no endian.h
, but it also looks like it is not needed.
Possible solution to make sha256.cpp
compile on OSX:
Replace
Lines 9 to 12 in a8a88f8
with
#if !defined(_MSC_VER) && !defined(__APPLE__)
#include <endian.h>
#endif
The "default" byte order is little endian (and your system is little endian, too).
If the __BYTE_ORDER
macro isnt defined then little endian is assumed - and thats the case if you skip #include <endian.h>
This preprocesser statement in line 98 "detects" big endian:
#if defined(__BYTE_ORDER) && (__BYTE_ORDER != 0) && (__BYTE_ORDER == __BIG_ENDIAN)
Big endian systems are rare nowadays.
Just removing the include might work for Macs but breaks the whole thing on big-endian Unix machines.
A better workaround is to wrap the include by another #ifndef __APPLE__
#include <machine/endian.h>
worked on Mac. Will that work on Unix?
To have support for both OSX and Linux/WIndows, you can use
#include <sys/types.h>