AcademySoftwareFoundation / Imath

Imath is a C++ and python library of 2D and 3D vector, matrix, and math operations for computer graphics
https://imath.readthedocs.io
BSD 3-Clause "New" or "Revised" License
357 stars 104 forks source link

Error compiling tests using glibc 2.17 #286

Open SimonBoorer opened 1 year ago

SimonBoorer commented 1 year ago

I'm getting errors building testFun.cpp using glibc 2.17 and Imath 3.1.6:

/home/bokken/build/output/unity/Imath/src/ImathTest/testFun.cpp:49:24: error: expected ')'
    printf ("f %.9g %" PRIx32 "\n", f, bit_cast<uint32_t> (f));
                       ^
/home/bokken/build/output/unity/Imath/src/ImathTest/testFun.cpp:49:12: note: to match this '('
    printf ("f %.9g %" PRIx32 "\n", f, bit_cast<uint32_t> (f));

In this version of glibc inttypes.h is like the following:

#if !defined __cplusplus || defined __STDC_FORMAT_MACROS
#define PRIu64 xxx
#endif 

Defining __STDC_FORMAT_MACROS before including inttypes.h fixes the issue, e.g.:

#define __STDC_FORMAT_MACROS
#include <inttypes.h>

The __STDC_FORMAT_MACROS macro was removed in glibc 2.18.

cary-ilm commented 1 year ago

Hey @SimonBoorer, thanks for the catches and the suggested fixes. Any chance we could talk you into submitting PR's? We would welcome the help, although it does involve signing the CLA. Thanks! And good to hear from you :)

SimonBoorer commented 1 year ago

Hi @cary-ilm! Yes I'd be happy to submit PR's, I'm just waiting on legal to sign a Corporate CLA.