Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Won't Fix
-
0.4
-
None
-
FreeBSD 7.2-RELEASE amd64
Description
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 :
php_thrift_protocol.cpp:
#include <sys/types.h>
#include <netinet/in.h>
#include <unistd.h>
#include <sys/endian.h> // <-- was endian.h
// #include <byteswap.h> // <-- doesn't exist under FreeBSD
#include <stdexcept>
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define htonll bswap64 // <-- was bswap_64
#define ntohll bswap64 // <-- was bswap_64
#else
#define htonll x
#define ntohll x
#endif
The lines that changed are the ones marked with "<--".
Please let me know if there's a better way to achieve this.