Skip to content

Fix some compilation warnings #718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

illwieckz
Copy link
Contributor

Some warning fixes by a contributor of Unvanquished, initially pulled from:

I modified the first commit commit of that branch to:

  1. extract a chmod change to a dedicated commit,
  2. deleted a leftover,
  3. move a change to the next commit it belongs to (partial downside squash).

@illwieckz illwieckz force-pushed the illwieckz/bmorel-warning-fixes branch from 8b242b4 to 624c744 Compare June 18, 2024 02:25
@illwieckz
Copy link
Contributor Author

illwieckz commented Jun 18, 2024

I'm reporting the macos, msvc and premake errors reported by the CI to bmorel.

@illwieckz illwieckz force-pushed the illwieckz/bmorel-warning-fixes branch 4 times, most recently from 02ec38e to 8c1eb0a Compare June 18, 2024 03:13
@illwieckz
Copy link
Contributor Author

illwieckz commented Jun 18, 2024

The remaining error happening with premake on Linux doesn't seem to be introduced by this branch:

 ../../Source/main.cpp:62:16: error: unused function 'createDebug' [-Werror,-Wunused-function]
static Sample* createDebug() { return new Sample_Debug(); }
               ^
1 error generated.

@illwieckz illwieckz force-pushed the illwieckz/bmorel-warning-fixes branch from 8c1eb0a to 3dc4e55 Compare June 20, 2024 03:13
@illwieckz
Copy link
Contributor Author

The remaining error happening with premake on Linux doesn't seem to be introduced by this branch:

 ../../Source/main.cpp:62:16: error: unused function 'createDebug' [-Werror,-Wunused-function]
static Sample* createDebug() { return new Sample_Debug(); }
               ^
1 error generated.

See this another PR for an attempt to fix that:

Copy link
Member

@grahamboree grahamboree left a comment

Choose a reason for hiding this comment

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

Thank you! Love this change! Especially using RC_NULL rather than 0 makes the code a lot clearer. There's a few small things I'd love to tweak a bit before merging it.

dtTileCacheAlloc& operator=( dtTileCacheAlloc const& ) = default;
dtTileCacheAlloc( dtTileCacheAlloc && ) = default;
dtTileCacheAlloc& operator=( dtTileCacheAlloc && ) = default;
#endif
Copy link
Member

Choose a reason for hiding this comment

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

Is this strictly necessary?
If it is, is there a version of this that would work for C++98 as well?

{
dtAssert( std::numeric_limits<TO>::min() <= val && val <= std::numeric_limits<TO>::max() );
return static_cast<TO>( val );
}
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem only applicable to "modern C++", so I'd be cool moving this to a DetourCommon.h

Also, I think a name like dtSafeNumericCast or dtCheckedNumericCast would be more appropriate here since this only works for numeric types, and it's checking that the value can be casted to the new type without losing information.

{
rcAssert( std::numeric_limits<TO>::min() <= val && val <= std::numeric_limits<TO>::max() );
return static_cast<TO>( val );
}
Copy link
Member

Choose a reason for hiding this comment

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

Same thoughts here as the Detour version...

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.

2 participants