Can we rely on #pragma once ?

Mark Kettenis mark.kettenis at xs4all.nl
Mon Feb 19 14:02:18 UTC 2024


> Date: Mon, 19 Feb 2024 12:13:34 +0100
> From: "Enrico Weigelt, metux IT consult" <info at metux.net>
> 
> Hello folks,

Hi Enrico,

> we've got a lot of include files, therefore lots of guards.
> 
> Modern C compilers should understand #pragma once, but this isn't
> without problems (possibly problematic with symlinks ?), and I have
> to admit I don't how well is it supported outside of GNU land.
> 
> Can we rely on it ?

IMHO, no.  There must be a reason why this hasn't been widely adopted,
despite having been around for the better part of 2- years.  And the
public Xorg headers should work with a standard C99 compiler.

To be honest, some of the things you've raised in this thread really
worry me.  I don't think Xorg is in a position where it makes sense to
do a large overhaul.  The code is used by a lot of projects, but many
of those projects probably don't have a lot of manpower to spend on
testing Xorg patches.  So breakage may not be caught in a timely
fashion unless you commit yourself to testing a wide variety of
platforms.

Looking at this particular thing, what problem are you trying to
solve?  The existing header files already have the protection in place
where it matters.  And I don't expect why software that's mostly just
in maintenance mode would see a lot of new header files being added.

Cheers,

Mark


> In fact, we already have one place using it:
> 
> include/xwayland-config.h.meson.in
> 
> But I doubt that xwayland is ever been compiled w/ non-gnu/non-clang
> compilers.


More information about the xorg-devel mailing list