This project 1 can compile on Windows and macOS (with a few minor tweaks). On Ubuntu it fails to compile, with a lot of errors like:
ldrawloader/src/ldrawloader.cpp:3214:19: note: candidate template ignored: deduced type 'LdrVector *' of 2nd parameter does not match adjusted type 'LdrVector *__restrict' of argument [with T = LdrVector, Tout = LdrVector] static uint32_t u32_append(LdrRawData& raw, Tout*& ptrRef, const Loader::TVector& vec, size_t divisor = 1)
I tried to switch to clang on Ubuntu (apt install clang
, then export CC=clang
, export CXX=clang++
, clean rebuild) but it still fails to compile (but I'm 100% sure I'm using clang and not gcc, as I see the compiler command invocation which starts with /usr/bin/clang++
and the compiler error is slightly different; in fact the error you see above is from clang-14 on Ubuntu).
According to 2, __restrict
can be removed and code should work in the same way. So I replaced #define LDR_RESTRICT __restrict
with #define LDR_RESTRICT
in src/ldrawloader.h:107 and now I can compile it successfully.
Question time:
- Why
__restrict
has been used there? - I have the same clang version (14.0.0) on Ubuntu and on macOS: why on macOS I've been able to compile it without modifications?