cemyuksel / cyCodeBase

An open source programming resource intended for graphics programmers.
MIT License
271 stars 60 forks source link

Old GCC will complain when building programs with this project #1

Closed wilsonCernWq closed 7 years ago

wilsonCernWq commented 7 years ago

I am using this code base for the ICG course this year, and I noticed some small problems when I was trying to build projects with GCC/intel-ICC compilers.

The first thing is that in some old c11 compilers, for example GCC-4+, function is_trivally_copyable is not implemented. It seems the best solution is to update the GCC. However sometimes it is hard to do so when you don't have root. I was trying to find a way to work-around. The way I found is to include boost's has_trivia_copy function inside the project, and implement my own version of is_trivally_copyable function. In order to do so, I needed to let the function search inside global namespace, so I added an additional code block with 'using namespace std;' in it. It should bring minimum effects to the whole program.

The second thing is that in some again old GLEW, the GLDEBUGPROC is wrongly implemented. (See https://sourceforge.net/p/glew/bugs/233/ ) The interface of GLDEBUGPROC is defined as (GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar message,void userParam) instead of const void userParam as the last argument. It becomes really a problem when you can't have the root access, or you can't update your GL library because of NVidia driver problems. I think adding a overloaded function will solve the problem temporarily (but not very nicely). However I feel it is better to make the code compile first.

Qi WU

cemyuksel commented 7 years ago

Thanks for the comments. I introduced some fixes for these and other issues with old C++ compilers. Check out the latest version.

wilsonCernWq commented 7 years ago

Hi Cem

I think my gcc and icc still complaining. My gcc is 4.8.5 and it doesn't have is_trivially_copyable' still:

cmake output: ... -- The C compiler identification is GNU 4.8.5 -- The CXX compiler identification is GNU 4.8.5 ...

make output: ... In file included from /home/sci/qwu/graphics/common/icg_common.h:79:0, from /home/sci/qwu/graphics/program/project2/main.cpp:1: /home/sci/qwu/graphics/external/cyCodeBase/cyPoint.h: In copy constructor 'cy::Point<TYPE, N>::Point(const cy::Point<TYPE, N>&)': /home/sci/qwu/graphics/external/cyCodeBase/cyCore.h:161:10: error: 'is_trivially_copyable' is not a member of 'std' { if ( !std::is_trivially_copyable() || (n)*sizeof(type) < _CY_CORE_MEMCPY_LIMIT ) { \ ...

wilsonCernWq commented 7 years ago

And gcc-4.8.5 doesn't like such way of initializing anonymous class also (I changed gcc minimum version to 50000 in order to skip previous error)

In file included from /home/sci/qwu/graphics/common/icg_common.h:79:0, from /home/sci/qwu/graphics/program/project2/main.cpp:1: /home/sci/qwu/graphics/external/cyCodeBase/cyCore.h:85:1: error: expected ';' after class definition } nullptr = {}; ^ /home/sci/qwu/graphics/external/cyCodeBase/cyCore.h:79:13: error: an anonymous struct cannot have function members const class { ^ /home/sci/qwu/graphics/external/cyCodeBase/cyCore.h:85:1: error: abstract declarator 'const' used as declaration } nullptr = {}; ^ /home/sci/qwu/graphics/external/cyCodeBase/cyCore.h:85:3: error: expected unqualified-id before 'nullptr' } nullptr = {};

cemyuksel commented 7 years ago

I addressed these issues in the latest version. I'm not sure why you are having problems with the nullptr implementation using gcc 4.8.5. Support for nullptr should be included in gcc version 4.6 and above. At any rate, I modified the implementation to address the compiler errors you listed.

wilsonCernWq commented 7 years ago

The code works perfectly now! Thanks