Skip to content

Fix a bunch of warnings#2254

Merged
alecjacobson merged 9 commits intomainfrom
alecjacobson/warnings
Aug 27, 2023
Merged

Fix a bunch of warnings#2254
alecjacobson merged 9 commits intomainfrom
alecjacobson/warnings

Conversation

@alecjacobson
Copy link
Copy Markdown
Contributor

Fixes #1637 as much as I'm willing to.

This introduces the CMake flag LIBIGL_WARNINGS_AS_ERRORS which doesn't really turn on all warnings but the ones I was willing to fix:

target_compile_options(${module_name} PRIVATE -Wall -Wextra -Wpedantic -Wno-sign-compare -Werror -Wno-gnu -Wno-unknown-pragmas)

I also wasn't willing to fix the warnings in the COMISO package and for some reason the compiler was finding warnings in the tetgen.h dependence even though that was supposed to be a system include and I thought they would be ignored.

The strong majority of the warnings were unused variables. If there were unused parameters I tried to remove those parameters (which will likely break some code; in a rather innocuous way).

Finally, there were some variables that show up just for assertions. It seems that C++ compilers don't have a good solution for this common problem. So I used the suggestion on SO.

#include <cassert>
#ifndef ASSERT
#ifdef NDEBUG
#define ASSERT(x) do { (void)sizeof(x);} while (0)
Copy link
Copy Markdown
Collaborator

@jdumas jdumas Aug 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to prefix this with IGL_. You never know what other codebase might be defining their own ASSERT macro, in ways that could be incompatible with the libigl one... (e.g. imagine another lib defines their own ASSERT(x, msg) to take two mandatory arguments).

@alecjacobson alecjacobson merged commit 6875302 into main Aug 27, 2023
@alecjacobson alecjacobson deleted the alecjacobson/warnings branch August 27, 2023 02:42
@William8915
Copy link
Copy Markdown
Contributor

This breaks the compilation on gcc-12.3 with c++20, the error is

WindingNumberTree.h:217:57: error: template-id not allowed for destructor
inline igl::WindingNumberTree<Point,DerivedV,DerivedF>::~WindingNumberTree<Point,DerivedV,DerivedF>()

@alecjacobson
Copy link
Copy Markdown
Contributor Author

alecjacobson commented Dec 20, 2023 via email

William8915 added a commit to William8915/libigl that referenced this pull request Jan 15, 2024
This is a follow up fix of libigl#2254. After libigl#2254 gcc-12.3 reports the error "template-id not allowed for destructor".
alecjacobson pushed a commit that referenced this pull request Feb 7, 2024
This is a follow up fix of #2254. After #2254 gcc-12.3 reports the error "template-id not allowed for destructor".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compiler warnings

3 participants