`htobe32` undeclared identifier on OS X
sivabudh opened this issue · 5 comments
Hi,
I'm trying to build the library on OS X El Capitan, but came across this error when performing a make
:
mkdir -p build/max-c++/obj/zmqpp/
c++ -MMD -std=c++11 -pipe -Wall -fPIC -DBUILD_ENV=max -DBUILD_DATESTAMP='"2016-06-14 20:35"' -DBUILD_LIBRARY_NAME='"zmqpp"' -DBUILD_CLIENT_NAME='"zmqpp"' -I./src -O3 -funroll-loops -ffast-math -finline-functions -fomit-frame-pointer -DNDEBUG -c -o build/max-c++/obj/zmqpp/zap_request.o src/zmqpp/zap_request.cpp
clang: warning: optimization flag '-finline-functions' is not supported
src/zmqpp/zap_request.cpp:111:29: error: use of undeclared identifier 'htobe32'
auto value_length = htobe32(static_cast<uint32_t>(pair.second.length()));
^
1 error generated.
make: *** [build/max-c++/obj/zmqpp/zap_request.o] Error 1
I am having this issue as well. It seems to be an issue that is in develop. The issue is resolved in previous tag 4.1.2.
This sounds vaguely similar to the issue regarding htons
/ htonl
/ ntohl
. I believe the correct way to fix this would be to add a function in zmqpp/inet.hpp
and call that one instead.
Having this also. Found this one, maybe this would helpful?
#ifdef __APPLE__
#include <libkern/OSByteOrder.h>
#define htobe16(x) OSSwapHostToBigInt16(x)
#define htole16(x) OSSwapHostToLittleInt16(x)
#define be16toh(x) OSSwapBigToHostInt16(x)
#define le16toh(x) OSSwapLittleToHostInt16(x)
#define htobe32(x) OSSwapHostToBigInt32(x)
#define htole32(x) OSSwapHostToLittleInt32(x)
#define be32toh(x) OSSwapBigToHostInt32(x)
#define le32toh(x) OSSwapLittleToHostInt32(x)
#define htobe64(x) OSSwapHostToBigInt64(x)
#define htole64(x) OSSwapHostToLittleInt64(x)
#define be64toh(x) OSSwapBigToHostInt64(x)
#define le64toh(x) OSSwapLittleToHostInt64(x)
#endif
This also causes an error on Windows that needs to redefine the conversion function to work. I'm currently trying to get a build working on Windows, so I'll see if I can resolve the OS X issue from this too.
Fixed via #174, so can probably be closed.