Repository navigation
Closed
Description
I'm trying to build assimp-3.1.1 on the redhat 7 ppc64 architecture. I'm getting the following error:
/builddir/build/BUILD/assimp-3.1.1/code/Bitmap.cpp: In instantiation of 'std::size_t Assimp::Copy(uint8_t*, T&) [with T = short unsigned int; std::size_t = long unsigned int; uint8_t = unsigned char]':
/builddir/build/BUILD/assimp-3.1.1/code/Bitmap.cpp:93:44: required from here
/builddir/build/BUILD/assimp-3.1.1/code/Bitmap.cpp:85:21: error: lvalue required as unary '&' operand
std::memcpy(data, &AI_BE(field), sizeof(field)); return sizeof(field);
^
/builddir/build/BUILD/assimp-3.1.1/code/Bitmap.cpp: In instantiation of 'std::size_t Assimp::Copy(uint8_t*, T&) [with T = unsigned int; std::size_t = long unsigned int; uint8_t = unsigned char]':
/builddir/build/BUILD/assimp-3.1.1/code/Bitmap.cpp:94:44: required from here
/builddir/build/BUILD/assimp-3.1.1/code/Bitmap.cpp:85:21: error: lvalue required as unary '&' operand
/builddir/build/BUILD/assimp-3.1.1/code/Bitmap.cpp: In instantiation of 'std::size_t Assimp::Copy(uint8_t*, T&) [with T = int; std::size_t = long unsigned int; uint8_t = unsigned char]':
/builddir/build/BUILD/assimp-3.1.1/code/Bitmap.cpp:108:42: required from here
/builddir/build/BUILD/assimp-3.1.1/code/Bitmap.cpp:85:21: error: lvalue required as unary '&' operand
make[2]: *** [code/CMakeFiles/assimp.dir/Bitmap.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
Full build log is here.
It looks like the source of this issue is the in-line use of the AI_BE(t) macro, which on big-endian architectures expands to ByteSwap::Swapped(t). Trying to pass a reference to the expanded statement to memcpy fails with the above error.
I was able to work around the issue by modifying the Copy function in Bitmap.cpp to create a temporary variable that holds the result of AI_BE, and then passing the temporary variable to memcpy.
Activity
umlaeute commentedon Aug 10, 2015
I can confirm the issue (now that i finally got around at packaging assimp-3.1.1 for Debian).
@jpgr87 could you share your workaround?
umlaeute commentedon Aug 10, 2015
probably something like:
or even simpler:
richmattes commentedon Aug 10, 2015
My fix is nearly identical to your "even simpler" approach. The patch I'm using can be found here
fix compilation on BigEndian