endian.h not found on mac osx

I just used <machine/endian.h> rather than <endian.h>.

It works.

As said in the first comment, endian.h is in /usr/include/machine/ folder.


Xcode on OS X does not install the command-line tools by default. Depending on your Xcode and OS X version you have to

  • install the command line tools from the Xcode Preferences->Downloads window, or
  • execute xcode-select --install from the Terminal command-line.

This will also install the "/usr/include" files, including "/usr/include/machine/endian.h".

For Xcode 10 and later, see Camille G.'s answer.