Usage of ANSI-C |const| in X11 code...

Alan Coopersmith Alan.Coopersmith at Sun.COM
Sat Mar 12 11:17:06 PST 2005


Roland Mainz wrote:
> Yeah, but note the underscore (indicating that it's more some
> (semi-)private stuff) - |_Xconst| is more a hack for the old days when
> K&R compilers needed to be supported. Since a while ANSI-C89 support is
> the minimum required and some code in libX11, Xserver and other places
> already uses |const| without causing complains. So my question is
> whether code can now "officially" use |const| directly (CC:'ing
> xorg-arch at lists.x.org as this is more an architecture question, IMO we
> need need a clear statement that ANSI-C89 is now the minimum level and
> all it's features[1] can be used by Xorg code) ...

I believe ANSI/ISO C89 as the minimum required was set in one of the old
X Consortium releases - 6.1 or 6.3 or so, many years ago.   Certainly the
ANSIfication work that people have done both in the XFree86 tree and ours
has replaced _Xconst with const in quite a few places already, so it's a
bit late to object now.

> [1]=Next question would be whether the |inline| keyword can be used in
> Xorg code - |inline| is newer than ANSI C89 (maybe C99 but I am not
> sure) but most compilers incl. gcc, Sun Workshop/Forte/One and the MS
> compiler support it right now...

inline is in C99, but this one's a little more problematic, as the
semantics differ slightly between the C99 standard version and the
various compilers pre-C99 extensions that added it, causing differences
in when a non-inline'd version is generated that other files can link
against.   See http://www.greenend.org.uk/rjk/2003/03/inline.html and
the inline notes on http://gcc.gnu.org/c99status.html

That said, there are a few places it's used already, though mainly in 
#ifdef's that check for gcc.   I did look at modifying some of them to
also check for __STDC_VERSION__, but never followed through.

And of course, once autoconf is in use, it provides checks to allow use
of inline as well.

-- 
	-Alan Coopersmith-           alan.coopersmith at sun.com
	 Sun Microsystems, Inc. - X Window System Engineering



More information about the xorg-arch mailing list