-
Notifications
You must be signed in to change notification settings - Fork 75
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
Use compiler warnings #118
Comments
I will soon be pushing out a code style change that will finally fix these issues once and for all. :) I previously opened an issue (#7) that tried to address this but I closed it due to inactivity. Feel free to make a PR that fixes all the warnings you listed. As an extension, I would like to use these compiler warnings as part our Travis CI pipeline, let me know if you feel up to the task - otherwise, I'll create a separate issue for it. |
OK, I'll create the PR in a few minutes.
|
Oh, we already have a CI pipeline. I completely missed that. Then the CMake build should work with the warnings. As for detecting them, I have no idea. |
The use of compiler warnings is good practice and they should be enabled for all projects. On GCC and Clang
-Wall
,-Wextra
, and-Wpedantic
should be enabled, while/W3
on MSVC.With this, multiple warnings are generated when compiling:
MSCV:
C4530
: Basically an MSVC-specific warning that one should add/EHsc
to the compile flags. This is a simple CMake script fix.GCC:
-Wmisleading-indentation
: In Player.cpp there are a fewelse
cases where the following line is indented with a tab. This is not really a misleading indentation problem and is mostly just a false positive on the compiler's part, but that tab should really be a set of spaces since that function is mostly indented with spaces. (Also the whole project's is completely mixed on tabs vs spaces. IMO as a separate issue this should be fixed.)-Wunused-variable
: Player.cpp:539 definesint countLength = 0;
which is not used anywhere and should be deleted.Clang:
-Winconsistent-missing-override
: Descendants of theEnemy
class seem to override virtual member functions such asGetIntro()
and others likeReturnDamage()
which come fromEntity
. These functions should be markedoverride
but they are not. I guess the compiler figures out what you wanted to do, but this is really bad practice. Note that this is triggered even if one passes no arguments to clang while compiling, as in this is a default warning.-Wunused-private-field
: The Game class's_Level
member is not used anywhere and should be deleted. (Also, identifiers starting with an underscore and then an upper case character (like_Level
, or_Player
) are reserved for implementations, and using them is undefined behavior)-Wreorder-ctor
: The member initializer list of SoundMaker class initializes members out of order. This is, iirc, UB, but most certainly nothing fun. Lines 77 and 76 should be swapped.I can make a PR with these fixes if it is going to be considered.
The text was updated successfully, but these errors were encountered: