On Thu, 12 Jan 2023 at 16:08, Daniel P. Berrangé <[email protected]> wrote: > I think the challenge is that osdep.h is too big as it exists > today. The stuff the needs to come before system headers is > actually little more than config-host.h and a few #defines > most of which are specific to windows. If those critical > #defines went into config-host.h, then we could have a rule > 'config-host.h' must be included in all .c files as the first > thing.
This doesn't seem much different to the rules we have today, except you've renamed osdep.h to config-host.h... > All the header files could just reference the specific > system headers they care about instead of making everything > from osdep.h visible in their namespace. Still this would be > quite a lot of work to adapt to at this point. It certainly does have more in it than strictly necessary, though we have thinned it out quite a bit from when we first put in the convention. A lot of the functions at the tail end of the file could be moved out into their own headers, for instance -- patches welcome ;-) > All the header files could just reference the specific > system headers they care about instead of making everything > from osdep.h visible in their namespace. There are some complicated things in there, not always limited to Windows. Also where there is some header that needs a platform-specific workaround I prefer that that header is pulled in by osdep.h. This avoids the failure mode of "developer working on Linux directly includes some-system-header.h; works fine on their machine, but doesn't work on oddball-platform where the header needs a workaround". (For instance, handling "sys/mman.h on this system doesn't define MAP_ANONYMOUS", or the backcompat stuff in glib-compat.h.) thanks -- PMM
