On Wed, 7 Aug 2024 at 12:10, Markus Armbruster <arm...@redhat.com> wrote: > Having to manually include a configuration header like CONFIG_DEVICES > wherever you use configuration symbols strikes me as unadvisable when > uses include checking for definedness, such as #ifdef: silent miscompile > when you forget to include. > > This is why Autoconf wants you to include config.h first in any .c: it > makes #ifdef & friends safe. > > qemu/osdep.h does include some configuration headers: > > #include "config-host.h" > #ifdef COMPILING_PER_TARGET > #include CONFIG_TARGET > #else > #include "exec/poison.h" > #endif > > Why not CONFIG_DEVICES?
The stuff in CONFIG_DEVICES is target-specific, so wanting to include it should be rare (currently we include it in only about 25 files). Any file that includes it has to be a compile-per-target file, and generally we'd rather avoid that. Plus it's a bit odd to need to change code based on whether some other device was configured into the system, so I think that's something worth restricting to only files that effectively opt in to it. thanks -- PMM