Ticket #133 (closed defect: fixed)
FreeBSD endian.hpp
| Reported by: | nrv2 | Owned by: | mloskot |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.2.1 |
| Component: | Base Library | Version: | 1.2 |
| Keywords: | endian | Cc: | cc |
| LAS Format Version: | Not Applicable |
Description (last modified by mloskot) (diff)
Hi, Thanks for providing such a great library. I have no complaints, but I have one little glitch that showed up for me... When building liblas on two FreeBSD systems, one i386, and one amd64, I ended up with a library that reads/writes in big-endian. After some investigation, the file include/liblas/detail/endian.hpp has the following lines appear after the initial test to see if GLIBC is defined (which it is not for me):
... #elif defined(_BIG_ENDIAN) # define LIBLAS_BIG_ENDIAN # define LIBLAS_BYTE_ORDER 4321 #elif defined(_LITTLE_ENDIAN) # define LIBLAS_LITTLE_ENDIAN # define LIBLAS_BYTE_ORDER 1234 ...
However, on my system both _BIG_ENDIAN and _LITTLE_ENDIAN are defined, as 4321 and 1234 respectively. So the first test for _BIG_ENDIAN wins, and this results in LIBLAS_BIG_ENDIAN being defined and a big-endian reader/writer. All is well if I comment out these six lines. In the header, the following tests for architecture definitions work correctly for both my systems. I did not get to try it on any other systems/OSes.
This was a pretty simple fix, and I already sent patches to the FreeBSD port maintainer for liblas. So if that code is necessary for other OS types, no change is needed. However, it would be great if no changes were needed to build on FreeBSD in the future.
I'm attaching my slightly modified endian.hpp in case the description above is not clear.
Thanks, Nick

