29/08/2022 14:18, Morten Brørup: > At SmartShare Systems we follow a coding convention of including the > declaration header file at the absolute top of the file implementing it. This > reveals at build time if anything is missing in the declaration header file. > The DPDK Project could do the same, and find bugs like this. > > Here's an example: > > foo.h: > ------ > // Declaration > static inline uint32_t bar(uint32_t x); > > foo.c: > ------ > #include <foo.h> // <-- Note: At the absolute top! > #include <stdint.h> > > // Implementation > static inline uint32_t bar(uint32_t x) > { > return x * 2; > } > > Following our coding convention will reveal that <stdint.h> is required for > using <foo.h>, and thus should be included in foo.h (not in foo.c) - because > someone else might include <foo.h>, and then <stdint.h> could be missing > there.
Yes we could follow this convention.