Trying to build either 2.1.0 or git HEAD results in
[ 17%] Building CXX object src/fileformat/CMakeFiles/pfsoutimgmagick.dir/pfsoutimgmagick.cpp.o
cd /tmp/PFSTOOLS/pfstools-git/obj-x86_64-linux-gnu/src/fileformat && /usr/lib/ccache/c++ -D_CRT_SECURE_NO_WARNINGS -I/tmp/PFSTOOLS/pfstools-git/obj-x86_64-linux-gnu -I/tmp/PFSTOOLS/pfstools-git/src/pfs -I/usr/include/OpenEXR -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu/ImageMagick-6 -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -o CMakeFiles/pfsoutimgmagick.dir/pfsoutimgmagick.cpp.o -c /tmp/PFSTOOLS/pfstools-git/src/fileformat/pfsoutimgmagick.cpp
In file included from /tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h:38,
from /tmp/PFSTOOLS/pfstools-git/src/pfs/pfs.h:45,
from /tmp/PFSTOOLS/pfstools-git/src/fileformat/pfsoutimgmagick.cpp:37:
/tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h: In member function 'virtual float& pfs::Array2DImpl::operator()(int, int)':
/tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h:173:9: error: '__assert_fail' was not declared in this scope; did you mean 'MagickCore::__assert_fail'?
173 | assert( col >= 0 && col < cols );
| ^~~~~~
In file included from /usr/include/ImageMagick-6/magick/memory_.h:22,
from /usr/include/ImageMagick-6/magick/MagickCore.h:125,
from /usr/include/ImageMagick-6/Magick++/Include.h:45,
from /usr/include/ImageMagick-6/Magick++.h:10,
from /tmp/PFSTOOLS/pfstools-git/src/fileformat/pfsoutimgmagick.cpp:32:
/usr/include/assert.h:69:13: note: 'MagickCore::__assert_fail' declared here
69 | extern void __assert_fail (const char *__assertion, const char *__file,
| ^~~~~~~~~~~~~
In file included from /tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h:38,
from /tmp/PFSTOOLS/pfstools-git/src/pfs/pfs.h:45,
from /tmp/PFSTOOLS/pfstools-git/src/fileformat/pfsoutimgmagick.cpp:37:
/tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h: In member function 'virtual const float& pfs::Array2DImpl::operator()(int, int) const':
/tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h:178:9: error: '__assert_fail' was not declared in this scope; did you mean 'MagickCore::__assert_fail'?
178 | assert( col >= 0 && col < cols );
| ^~~~~~
In file included from /usr/include/ImageMagick-6/magick/memory_.h:22,
from /usr/include/ImageMagick-6/magick/MagickCore.h:125,
from /usr/include/ImageMagick-6/Magick++/Include.h:45,
from /usr/include/ImageMagick-6/Magick++.h:10,
from /tmp/PFSTOOLS/pfstools-git/src/fileformat/pfsoutimgmagick.cpp:32:
/usr/include/assert.h:69:13: note: 'MagickCore::__assert_fail' declared here
69 | extern void __assert_fail (const char *__assertion, const char *__file,
| ^~~~~~~~~~~~~
In file included from /tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h:38,
from /tmp/PFSTOOLS/pfstools-git/src/pfs/pfs.h:45,
from /tmp/PFSTOOLS/pfstools-git/src/fileformat/pfsoutimgmagick.cpp:37:
/tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h: In member function 'virtual float& pfs::Array2DImpl::operator()(int)':
/tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h:184:9: error: '__assert_fail' was not declared in this scope; did you mean 'MagickCore::__assert_fail'?
184 | assert( index >= 0 && index < rows*cols );
| ^~~~~~
In file included from /usr/include/ImageMagick-6/magick/memory_.h:22,
from /usr/include/ImageMagick-6/magick/MagickCore.h:125,
from /usr/include/ImageMagick-6/Magick++/Include.h:45,
from /usr/include/ImageMagick-6/Magick++.h:10,
from /tmp/PFSTOOLS/pfstools-git/src/fileformat/pfsoutimgmagick.cpp:32:
/usr/include/assert.h:69:13: note: 'MagickCore::__assert_fail' declared here
69 | extern void __assert_fail (const char *__assertion, const char *__file,
| ^~~~~~~~~~~~~
In file included from /tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h:38,
from /tmp/PFSTOOLS/pfstools-git/src/pfs/pfs.h:45,
from /tmp/PFSTOOLS/pfstools-git/src/fileformat/pfsoutimgmagick.cpp:37:
/tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h: In member function 'virtual const float& pfs::Array2DImpl::operator()(int) const':
/tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h:188:9: error: '__assert_fail' was not declared in this scope; did you mean 'MagickCore::__assert_fail'?
188 | assert( index >= 0 && index <= rows*cols );
| ^~~~~~
In file included from /usr/include/ImageMagick-6/magick/memory_.h:22,
from /usr/include/ImageMagick-6/magick/MagickCore.h:125,
from /usr/include/ImageMagick-6/Magick++/Include.h:45,
from /usr/include/ImageMagick-6/Magick++.h:10,
from /tmp/PFSTOOLS/pfstools-git/src/fileformat/pfsoutimgmagick.cpp:32:
/usr/include/assert.h:69:13: note: 'MagickCore::__assert_fail' declared here
69 | extern void __assert_fail (const char *__assertion, const char *__file,
| ^~~~~~~~~~~~~
In file included from /tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h:38,
from /tmp/PFSTOOLS/pfstools-git/src/pfs/pfs.h:45,
from /tmp/PFSTOOLS/pfstools-git/src/fileformat/pfsoutimgmagick.cpp:37:
/tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h: In function 'void pfs::copyArray(const pfs::Array2D*, pfs::Array2D*)':
/tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h:223:7: error: '__assert_fail' was not declared in this scope; did you mean 'MagickCore::__assert_fail'?
223 | assert( from->getRows() == to->getRows() );
| ^~~~~~
In file included from /usr/include/ImageMagick-6/magick/memory_.h:22,
from /usr/include/ImageMagick-6/magick/MagickCore.h:125,
from /usr/include/ImageMagick-6/Magick++/Include.h:45,
from /usr/include/ImageMagick-6/Magick++.h:10,
from /tmp/PFSTOOLS/pfstools-git/src/fileformat/pfsoutimgmagick.cpp:32:
/usr/include/assert.h:69:13: note: 'MagickCore::__assert_fail' declared here
69 | extern void __assert_fail (const char *__assertion, const char *__file,
| ^~~~~~~~~~~~~
In file included from /tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h:38,
from /tmp/PFSTOOLS/pfstools-git/src/pfs/pfs.h:45,
from /tmp/PFSTOOLS/pfstools-git/src/fileformat/pfsoutimgmagick.cpp:37:
/tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h: In function 'void pfs::multiplyArray(pfs::Array2D*, const pfs::Array2D*, const pfs::Array2D*)':
/tmp/PFSTOOLS/pfstools-git/src/pfs/array2d.h:253:7: error: '__assert_fail' was not declared in this scope; did you mean 'MagickCore::__assert_fail'?
253 | assert( x->getRows() == y->getRows() );
| ^~~~~~
In file included from /usr/include/ImageMagick-6/magick/memory_.h:22,
from /usr/include/ImageMagick-6/magick/MagickCore.h:125,
from /usr/include/ImageMagick-6/Magick++/Include.h:45,
from /usr/include/ImageMagick-6/Magick++.h:10,
from /tmp/PFSTOOLS/pfstools-git/src/fileformat/pfsoutimgmagick.cpp:32:
/usr/include/assert.h:69:13: note: 'MagickCore::__assert_fail' declared here
69 | extern void __assert_fail (const char *__assertion, const char *__file,
| ^~~~~~~~~~~~~
make[2]: *** [src/fileformat/CMakeFiles/pfsoutimgmagick.dir/build.make:66: src/fileformat/CMakeFiles/pfsoutimgmagick.dir/pfsoutimgmagick.cpp.o] Error 1
make[2]: Leaving directory '/dev/shm/PFSTOOLS/pfstools-git/obj-x86_64-linux-gnu'
make[1]: *** [CMakeFiles/Makefile2:859: src/fileformat/CMakeFiles/pfsoutimgmagick.dir/all] Error 2
make[1]: Leaving directory '/dev/shm/PFSTOOLS/pfstools-git/obj-x86_64-linux-gnu'
make: *** [Makefile:155: all] Error 2
Contary to the title I don't belive this is related to g++-10, I was able to reproduce it with g++-9
The issue is that Magick++.h (indirectly) includes assert.h inside a namespace.
Note that generally only the first include of a header actually does anything due to the presense of include gaurds.
Therefore if assert.h is included before Magick++.h then everything is fine, the symbols from assert.h are correctly
included in the global namespace. OTOH if the first include of assert.h is the one from Magick++.h then the symbols
from assert.h are defined in the MagickCore namespace which breaks stuff.
I would argue that is a bug in imagemagick and have filed bugs in both Debian and upstream as
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=969128 and https://github.com/ImageMagick/ImageMagick6/issues/95
Nevertheless this can be worked around fairly easily in pfstools by re-ordering the includes so that pfs.h
(which includes assert.h) is included before Magick++.h . I have done so in Raspbian bullseye-staging
A patch doing so can be found at
https://github.com/raspbian-packages/pfstools/blob/bullseye-staging/debian/patches/reorder-includes-imagemagick.patch