Hi Arthur, list, On Sun, May 15, 2022 at 6:56 PM Arthur Heymans <art...@aheymans.xyz> wrote: > > Hi > > To make sure headers don't create conflicts, guards are added to all of them. > But the guard needs to be correct: e.g. > https://review.coreboot.org/c/coreboot/+/64360/2 > Most compilers implement '#pragma once ' as an alternative. > Should we use this instead across the tree, as it is less error prone and > less code?
Given that coreboot is built with a very specific toolchain, it seems very reasonable. The only thing that worries me are headers used to build stuff with the system toolchain, e.g. util/ and src/commonlib/ headers. Still, it's highly unlikely that the system toolchain doesn't know about #pragma once provided that it is able to build crossgcc. > Sidenote: clang warns about wrong header guards. > https://review.coreboot.org/c/coreboot/+/62173/23 hooks up clang to our CI > for some platforms ;-). And mismatched names in #ifndef and #define is not the only problem. I recently pondered about the scenario in which a compilation unit includes two different header files that use the same name in their guard. Using #pragma once would fundamentally eliminate both problems. > Kind regards > Arthur Best regards, Angel _______________________________________________ coreboot mailing list -- coreboot@coreboot.org To unsubscribe send an email to coreboot-le...@coreboot.org