Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSX has no endian.h #1

Open
NiklasRosenstein opened this issue Sep 12, 2018 · 5 comments · May be fixed by #4
Open

OSX has no endian.h #1

NiklasRosenstein opened this issue Sep 12, 2018 · 5 comments · May be fixed by #4

Comments

@NiklasRosenstein
Copy link

NiklasRosenstein commented Sep 12, 2018

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

hash-library/sha256.cpp

Lines 9 to 12 in a8a88f8

// big endian architectures need #define __BYTE_ORDER __BIG_ENDIAN
#ifndef _MSC_VER
#include <endian.h>
#endif

with

#if !defined(_MSC_VER) && !defined(__APPLE__)
#include <endian.h>
#endif
@stbrumme
Copy link
Owner

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.

@thomthom
Copy link

thomthom commented Dec 9, 2018

I made this change to be able to compile on mac:

2018-12-09_13h03_35

@stbrumme
Copy link
Owner

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__

@thomthom
Copy link

#include <machine/endian.h> worked on Mac. Will that work on Unix?

@RaresAil
Copy link

To have support for both OSX and Linux/WIndows, you can use

#include <sys/types.h>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants