Error building on Ubuntu: "error: this 'if' clause does not guard"
I'm having an issue trying to build on Ubuntu 20.04 Linux. I cannot build from source due to the following error(attaching image):
I ran both cmake and make in the regular sense.
Specs
gcc 9.0.3 make 4.2.1 cmake 3.16.3
Regards,
PMA
FWIW: I can build on CentOS 7 just fine 🙂
@Kingcitaldo125 this warning is because if then else are poorly indented and can be misinterpreted by a human but definitively not an error inside the code. Try compiling without -Werror or call clang-format to fix indentation before compiling. I have a Debian 10 and this project compiles fine.
@Lecrapouille The suggestion that you've given appears to work. If the builds are allowed to fail even with that default TREAT_WARNINGS_AS_ERRORS flag turned on, then I don't think that there would be an issue.
If the builds are supposed to compile across multiple distros with the default compiler flags, regardless of things like indentation, then I believe the issue still remains.
Regardless, I wanted to bring this to the attention of those to whom it would pertain.
Yes your remark is true but this is a dead project (no longer maintained for 7 years). Probably this warning has been added in recent g++. On my side I simply commented:
CMakeLists.txt
if(THREE_TREAT_WARNINGS_AS_ERRORS)
set(THREE_COMMON_FLAGS "${THREE_COMMON_FLAGS} -Werror")
endif()
Could be nice if this project could live back and be based to a more recent version of three.js while I'm unsure that a portage 'as it' from JS is a good idea except as mention just for the fun. I'm using this project as a base of idea for doing my own engine.
Yup, that's also what I did on my end. I got the impression that the purpose behind this project was not meant to be taken 100% seriously, and that it was done "For the kids.". I still think the issue is a good thing to keep around, open or closed. Someone having a similar issue could see this and use it to help break a barrier.
"For the kids." => What I dislike about three.js code is that the renderer holds all stuffs from the Earth, making it difficult to read and understanding the code. The good point of the C++ version is the shader lib has small code of shaders that can be put together into a great shader (material).
I'm refactoring my project inspired by it (as well as Glumpy and Unity). Currently not all my features are working well for the moment but I think some of my parts are more simple than three.js and code is more compact: Geometry just generates vertices, Material generates the shader, a Shape joins Geometry and Material: hold a GLProgram and a VAO created from the shader: the VAO holds VBO filled by Geometry and material properties are uniforms of the shader. Shapes are nodes of SceneTree. In Unity, SceneTree class hierarchy is a little weird to me (you inherited from Transform class which is a SceneTree Node this can simplify things but weird point of view of the inheritance). I'm trying to do proper class but this is hard. If you are interested, you can help or get inspired
Hey folks, I'm quite flattered that there's still some residual interest in the project, despite it not having been touched in nearly a decade (how has it been that long!?). I suspect there are many similar footguns, stylistic violations and code quality issues throughout the project, and while I'm happy to entertain very simple pull requests, there are probably better supported and more robust projects out there for those of us still clinging to C++.
So, if somebody wants to submit a fix for the indentation issue here (or potentially elsewhere in the code), I'd be more than happy to merge it, but I probably won't be entertaining more invasive refactorings, updates or cleanups in the near future.
@jdduke Yes that does not make us younger :) Your project is still, as far as I could see, the best of three.js 'as it' portage. I'm pretty sure that some PR will make you stimulate to back to job :) Joke appart, I can make a PR for adding a .clang format file but the desired coding style is a dangerous opened door to trolls :)