GreycLab / CImg

The CImg Library is a small and open-source C++ toolkit for image processing
http://cimg.eu
Other
1.48k stars 282 forks source link

error: invalid pure specifier (only ‘= 0’ is allowed) before ‘<=’ token #347

Closed marriusco closed 2 years ago

marriusco commented 2 years ago

Hi, Why I am getting these. g++ or gcc yields same errors. gcc/g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0


gcc -std=c++11 -Dcimg_use_jpeg -Dcimg_display=0 -fexceptions -Wall -fpermissive -fstack-protector-all -g -O0 -o CMakeFiles/liveimage.dir/httpcam.cpp.o -c /home/marius/_gh/lili/httpcam.cpp
In file included from /home/marius/_gh/lili/httpcam.cpp:5:
/home/marius/_gh/lili/CImg.h: In member function ‘cimg_library::CImg<typename cimg_library::cimg::superset2<T, t, float>::type> cimg_library::CImg<T>::_correlate(const cimg_library::CImg<t>&, unsigned int, bool, unsigned int, int, int, int, int, int, int, int, int, int, float, float, float, float, float, float, bool, bool) const’:
/home/marius/_gh/lili/CImg.h:38670:46: error: invalid pure specifier (only ‘= 0’ is allowed) before ‘<=’ token
38670 |             CImg<Ttfloat> _res = channel_mode<=1?res.get_shared_channel(c):
      |                                              ^~
/home/marius/_gh/lili/CImg.h:38735:48: error: invalid pure specifier (only ‘= 0’ is allowed) before ‘<=’ token
38735 |               CImg<Ttfloat> _res = channel_mode<=1?res.get_shared_channel(c):
      |                                                ^~
/home/marius/_gh/lili/CImg.h:38802:48: error: invalid pure specifier (only ‘= 0’ is allowed) before ‘<=’ token
38802 |               CImg<Ttfloat> _res = channel_mode<=1?res.get_shared_channel(c):
      |                                                ^~
/home/marius/_gh/lili/CImg.h:38870:44: error: invalid pure specifier (only ‘= 0’ is allowed) before ‘<=’ token
`38870 |           CImg<Ttfloat> _res = channel_mode<=1?res.get_shared_channel(c):
``
dtschump commented 2 years ago

I have the same compiler here, running also on Ubuntu 20.04, but I don't get this error on any of my projects using CImg. Could you provide a minimal example of a .cpp file where the error occurs? Thanks.

circinusX1 commented 2 years ago

Hi, Me again, the project account. https://github.com/circinusX1/lili just uncomment in httpcam.cpp the include Cimg.h Appreciate. Thank you.

cmake . && make

dtschump commented 2 years ago

OK, tested and reproduced the issue. Moving the #include "CImg.h" at the top of the file (first include) solves this problem. My guess : there is a macro channel_mode defined in the other includes that break the thing (not checked though). Definitely not an issue with CImg, at least.

marriusco commented 2 years ago

Yes there Is, I spot that in resolv.h but the compiler erro did not lead me to that. Thank you appreciate the light speed answer. Cheers!

dtschump commented 2 years ago

Ha yes, that's _res being redefined. Not a really good idea if you ask me :)