When trying to compile the Thrift 0.4 PHP extension under FreeBSD 7.2-RELEASE amd64, I faced these errors when running 'make' :
php_thrift_protocol.cpp:27:20: error: endian.h: No such file or directory
php_thrift_protocol.cpp:28:22: error: byteswap.h: No such file or directory
php_thrift_protocol.cpp:466: error: 'bswap_64' was not declared in this scope
php_thrift_protocol.cpp:474: error: 'bswap_64' was not declared in this scope
Here's the changes that allowed me to successfully compile it :
#include <sys/endian.h> // <-- was endian.h
// #include <byteswap.h> // <-- doesn't exist under FreeBSD
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define htonll bswap64 // <-- was bswap_64
#define ntohll bswap64 // <-- was bswap_64
#define htonll x
#define ntohll x
The lines that changed are the ones marked with "<--".
Please let me know if there's a better way to achieve this.