zeiss-microscopy / libCZI

Open Source Cross-Platform C++ library to read CZI image files
GNU General Public License v3.0
71 stars 19 forks source link

alligned_alloc gcc compatibility #35

Closed elhuhdron closed 4 years ago

elhuhdron commented 6 years ago

alligned_alloc is not well supported in all versions of libstdc++, for example this bug report, so some g++ versions complain that it is missing even with #include <cstdlib> and using the namespace std::aligned_alloc.

Src/libCZI/stdAllocator.cpp already contains platform specific code, so would it be possible to change the aligned_alloc call to use posix_memalign instead? Specifically, change in Src/libCZI/stdAllocator.cpp:

#if defined(__GNUC__)
        //return aligned_alloc(32, size);
        void *pv;
        int res = posix_memalign(&pv, 32, size);
        return pv;
#else

I've verified this change works with g++ 6.4 and 7.3. I can provide a pull request if desired.

elhuhdron commented 4 years ago

Issue was worked around.