Add nonstring attribute to fix Clang build errors#282
Merged
mutability merged 1 commit intoflightaware:devfrom Mar 25, 2026
Merged
Add nonstring attribute to fix Clang build errors#282mutability merged 1 commit intoflightaware:devfrom
mutability merged 1 commit intoflightaware:devfrom
Conversation
These character arrays are intentionally sized to exactly fit their contents without a null terminator - they are used as lookup tables, not C strings. Modern Clang fails to build with -Werror due to -Wunterminated-string-initialization. The nonstring attribute documents the intent and silences the error without requiring global compiler flag changes.
This was referenced Mar 25, 2026
|
Thanks, & sorry it took so long to get to this! |
This was referenced Mar 25, 2026
Closed
|
This actually fails on clang-20, do you know the minimum clang version to support the attribute? https://github.com/flightaware/dump1090/actions/runs/23574105571/job/68642789458 (I'll put together some conditional compilation) |
mutability
added a commit
that referenced
this pull request
Mar 26, 2026
clang-20 complains by default about unrecognized attributes, so only include nonstring for >= 21 Do the same for gcc <10, since we don't do any testing on those older versions. This should fix some clang fallout from merging #282
|
Could you check that the dev branch including 34ecd43 works okay on clang-21? (I don't have a clang-21 readily accessible) |
Author
|
@mutability i checked llvm21/clang21 at commit 34ecd43 and it compiles successfully. i checked clang22 also and it works as well. you're all good now. |
Author
|
nice macro. copied for my project https://github.com/zfogg/ascii-chat/blob/master/include/ascii-chat/common.h#L94-L99 |
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
__attribute__((nonstring))to two character arrays that are intentionally sized without room for a null terminator-Werroris enabledDetails
The
ais_charset(64-char AIS lookup table) andspinner(4-char animation) arrays are used as raw byte lookup tables, not C strings. Clang's-Wunterminated-string-initializationwarning (promoted to error by-Werror) causes the build to fail.The
nonstringattribute is the idiomatic fix—it documents intent and is more targeted than disabling the warning globally via compiler flags.Test plan