Fix -Werror=implicit-fallthrough build failure in crafting.c - #201
Merged
p2r3 merged 1 commit intoAug 22, 2026
Merged
Conversation
Two switch blocks in getCraftingOutput() intentionally fall through between case groups (slab recipes into shovel/sword recipes, and the axe recipe guard into helmet recipes) so that shared items like oak_planks/cobblestone are checked against both recipe sets. GCC's -Wimplicit-fallthrough (enabled by default in ESP-IDF/PlatformIO builds) flags these as errors since they aren't annotated, breaking the ESP32 build as reported in p2r3#194. Annotate both intentional fallthroughs with __attribute__((fallthrough)), which is supported by GCC/Clang independent of the C standard version (the project targets C89 compatibility, so C23's [[fallthrough]] isn't an option, per the prior discussion in p2r3#81).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-Werror=implicit-fallthroughon two spots ingetCraftingOutput()insrc/crafting.c.oak_planks/cobblestoneget checked against both recipe sets). The fix annotates them with__attribute__((fallthrough));instead of adding abreak;, since a barebreak(as suggested in the issue thread) would silently remove the shovel/sword/helmet recipes for wood, stone, and leather items.__attribute__((fallthrough))is a GCC/Clang extension independent of the C standard version, so it works under this project's C89-compatibility goal (per the discussion in Convert all source code to C89 #81 about not using C23's[[fallthrough]]).Test plan
error: unannotated fall-through between switch labelsat both call sites) by compiling the pre-fixcrafting.cwith-Wimplicit-fallthrough -Werror.