Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Move return so that switch has default case#157

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
eaaltonen wants to merge1 commit intodocopt:master
base:master
Choose a base branch
Loading
fromvaisala-oss:fix-swich-missing-default-case

Conversation

@eaaltonen
Copy link

Commit

  • Move return so that switch has default case

When a project using docopt.cpp is built with-Werror=switch-default
option, there's an error

error: switch missing default case [-Werror=switch-default]

which this fixes.

Signed-off-by: Eero Aaltoneneero.aaltonen@vaisala.com

@jaredgrubb
Copy link
Member

This style is intentional.

There is another warning (-Wswitch) that warns if you forget to handle any enum case, but it gets disabled if you add a default (because that's signaling that youintend to cover "everything else not yet mentioned"). However, that's not the case here, as we want to be sure that we always explicitly handle every possible case.

I personally preferWswitch-enum which warnseven if you have a default, but that warning tends to get very noisy on legacy code-bases so is less used (I don't know this for sure, but just anecdotally).

I personally prefer the style as it is (as it's compatible with bothWswitch andWswitch-enum). I'll leave this open to hear other opinions though!

When a project using docopt.cpp is built with `-Werror=switch-default`option, there's an error```error: switch missing default case [-Werror=switch-default]```which this fixes.Signed-off-by: Eero Aaltonen <eero.aaltonen@vaisala.com>
@eaaltoneneaaltonenforce-pushed thefix-swich-missing-default-case branch from729cbe7 toaf11f9aCompareApril 11, 2024 10:44
@eaaltonen
Copy link
Author

I changed the commit so that the warning/error is silenced using a gcc pragma instead. Would you find that acceptable?

@eaaltonen
Copy link
Author

@jaredgrubb Care to take a look? By suppressing the warning the library could be used also by code that compiles withswitch-default.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@eaaltonen@jaredgrubb

[8]ページ先頭

©2009-2025 Movatter.jp