-
-
Notifications
You must be signed in to change notification settings - Fork 433
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
Fix archlinux compilation by fixing error-warnings ignored qualifiers
and implicit fallthrough
#3270
Fix archlinux compilation by fixing error-warnings ignored qualifiers
and implicit fallthrough
#3270
Conversation
How bad is it to fix |
Ill post the |
There are 2 warnings each.
(only 2 in the whole project?)
Seeing that there are only 2 warnings each, one could fix these imo. (all warnings when compiling: https://pastebin.com/tfxaitET) |
I do not have the knowledge to fix the |
I think it's just removing some of the |
This could use the workaround of #3275. |
I fixed the 2 warnings for Is this PR ok like this? |
@@ -317,7 +317,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) | |||
2 * QApplication::startDragDistance()) | |||
return; | |||
if (zone->getIsView()) { | |||
const ZoneViewZone *const view = static_cast<const ZoneViewZone *const>(zone); | |||
const ZoneViewZone *view = static_cast<const ZoneViewZone *>(zone); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the const
from the pointer since the type of zone
is non-const pointer.
Cockatrice/cockatrice/src/carditem.h
Line 23 in 89ab7f1
CardZone *zone; |
c++17 adds a #ifndef __has_cpp_attribute
# define __has_cpp_attribute(x) 0
#endif
#if __has_cpp_attribute(clang::fallthrough)
# define MOZ_FALLTHROUGH [[clang::fallthrough]]
#elif __has_cpp_attribute(gnu::fallthrough)
# define MOZ_FALLTHROUGH [[gnu::fallthrough]]
#elif defined(_MSC_VER)
/*
* MSVC's __fallthrough annotations are checked by /analyze (Code Analysis):
* https://msdn.microsoft.com/en-us/library/ms235402%28VS.80%29.aspx
*/
# include <sal.h>
# define MOZ_FALLTHROUGH __fallthrough
#else
# define MOZ_FALLTHROUGH /* FALLTHROUGH */
#endif usage switch(test)
{
case 1:
break;
case 2:
MOZ_FALLTHROUGH
default:
break;
} |
where should I add the MOZ_FALLTHROUGH macro? a new header file? |
Yep, that's the idea, and then |
That is working. (Sorry for the many edits) We should credit the mozilla guys for the macro right? |
That should do it, the macro should be tested on other platforms (clang, osx, windows) Both warnings are fixed in the code, CMakeLists.txt remains untouched. |
cockatrice/src/gamesmodel.cpp
Outdated
@@ -197,6 +198,7 @@ QVariant GamesModel::headerData(int section, Qt::Orientation /*orientation*/, in | |||
case Qt::TextAlignmentRole: | |||
return Qt::AlignCenter; | |||
} | |||
SWITCH_FALLTHROUGH; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry i didn't look at the code before bringing up the MOZ_FALLTHROUGH topic, but here a simple break;
would have avoided the warning without the need of adding a new header file.
To be precise, we don't want it to fall through.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the other switch statement is the same I could just add a break there too. Remove the header file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, sorry again for the wasted time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding a break
in these places makes the compiler think that the control could reach the end of the function error: control reaches end of non-void function [-Werror=return-type]
since the switch defaults to return QVariant();
I think ill add it at the end of the function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another idea would be adding default cases to both the switches returning QVariant(), this is done alot in the function above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or, you can add return QVariant()
in place of the breaks
…gnored qualifiers
ok, added the defaults to the switches |
Can you update your starting post? @berserkingyadis |
ignored qualifiers
and implicit fallthrough
updated, should reflect the changes now. |
Merged, thank you! |
Related Ticket(s)
Short roundup of the initial problem
Compiling the newest Cockatrice fails under Archlinux. These are the cmake options I have used:
-DCMAKE_BUILD_TYPE=Debug -DWITH_SERVER=1
Output:
https://hastebin.com/ajahasacow.rb
https://hastebin.com/esigarajun.vbs
What will change with this Pull Request?