Repository navigation
OIL 41, F-5: every file includes what it uses - #113
Merged
Merged
Conversation
PROGMEM and the reads from flash in avr/pgmspace.h, SREG in avr/io.h and cli() in avr/interrupt.h, which Arduino.h includes as the core's does. A file of the library can then include what it uses (F-5) and compile on the host and the board alike.
A sketch includes MaxMatrix.h alone, and names ModuleType, Sprite, Byte, make_array() and the rest through it. // IWYU pragma: export says so to misc-include-cleaner (F-5), which would otherwise ask a sketch for Matrix/Panel.h or Utility/array.h.
<stdint.h> and <stddef.h> rather than <cstdint>, which avr-gcc lacks; <avr/pgmspace.h> for PROGMEM and the reads from flash, <avr/io.h> and <avr/interrupt.h> for SREG and cli(). MaxMatrixErrorReport.cpp includes MaxMatrixError.h only where it uses it, with MAXMATRIX_DEV_ERROR_DETECT, and keeps MaxMatrixConfig.h, whose switch the build may set with -D.
…F-5) The rest of what a sketch names comes through MaxMatrix.h.
MaxMatrixTestSupport.h exports MaxMatrix.h, so that a test reaches the library through it alone: one that included Font/Font.h itself would have it sorted before #define private public. The headers of GoogleTest, the mock and the model each test includes itself. <fcntl.h> and <arpa/inet.h> went where nothing used them: htons() comes with <netinet/in.h>.
<arpa/inet.h>, <stdio.h> and <array> went where nothing used them. Four headers of wxWidgets that include only the port's header, and <sys/time.h> for timeval, which glibc declares in bits/, stay with // IWYU pragma: keep.
IgnoreHeaders leaves out what a public header includes and include-cleaner takes for a name's provider, as the template does for avr/io*.h: avr/common.h, glibc's bits/ and sys/poll.h, Linux's asm-generic/ and the GTK port of wxWidgets. Decided against a NOLINT on each of some 20 lines.
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.
What
Nothing changes for a sketch: it still includes
MaxMatrix.halone, and every example is the same size. Every file of the repository now includes what it uses, as F-5 ofdocs/CodingStyle.mdasks, andmisc-include-cleanerchecks it, which was the last check of the template still off (OIL 41).Why
A file that gets a name only through another header breaks when that header changes, and does not say what it depends on. The check was off because its own fix names
<cstdint>, which avr-gcc lacks, and<avr/pgmspace.h>, which the host's mock did not have.<stdint.h>and<stddef.h>, as the template and Utl write them.MaxMatrix.hmarks the headers whose names a sketch uses as exported, so that a sketch is not asked to include parts of the library. A sketch includes what it uses of avr-libc itself; the examples now include<stdint.h>, and<avr/pgmspace.h>where they keep a table in flash.avr/pgmspace.h,avr/io.handavr/interrupt.h, as the core has them, so the library includes the same headers on the host and the board.avr/common.hbehind<avr/io.h>, glibc'sbits/, Linux'sasm-generic/, the GTK port of wxWidgets),.clang-tidyleaves it out, as the template already does foravr/io*.h; decided against aNOLINTon each of some 20 lines.avr/common.his one for the template as well, whose pattern misses it.How it was checked
make checkpasses,make avrincluded, with 100 % of lines, branches and conditions.make examplesonmainand on this branch: flash and RAM of every example are the same in all three variants.make checkwithout a change afterwards: 100 s, as after the template's v0.11.1.