From owner-freebsd-hackers@FreeBSD.ORG Fri Jan 16 17:57:49 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EBD4B16A4CE; Fri, 16 Jan 2004 17:57:48 -0800 (PST) Received: from phantom.cris.net (phantom.cris.net [212.110.130.74]) by mx1.FreeBSD.org (Postfix) with ESMTP id D458F43D1D; Fri, 16 Jan 2004 17:57:42 -0800 (PST) (envelope-from ru@FreeBSD.org.ua) Received: from phantom.cris.net (ru@localhost [127.0.0.1]) by phantom.cris.net (8.12.10/8.12.10) with ESMTP id i0H1wCjm011273; Sat, 17 Jan 2004 03:58:12 +0200 (EET) (envelope-from ru@FreeBSD.org.ua) Received: (from ru@localhost) by phantom.cris.net (8.12.10/8.12.10/Submit) id i0H1wAmg011268; Sat, 17 Jan 2004 03:58:10 +0200 (EET) (envelope-from ru) Date: Sat, 17 Jan 2004 03:58:10 +0200 From: Ruslan Ermilov To: Tim Kientzle Message-ID: <20040117015809.GJ9410@FreeBSD.org.ua> References: <40088E75.5080908@acm.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="aznLbwQ42o7LEaqN" Content-Disposition: inline In-Reply-To: <40088E75.5080908@acm.org> User-Agent: Mutt/1.5.5.1i cc: hackers@FreeBSD.org cc: Garrett Wollman cc: David O'Brien cc: Dag-Erling Smorgrav cc: Mike Barcroft Subject: Re: __restrict__ vs __restrict ? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Jan 2004 01:57:49 -0000 --aznLbwQ42o7LEaqN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jan 16, 2004 at 05:23:01PM -0800, Tim Kientzle wrote: > I've been enabling a LOT of gcc warnings recently > in the process of linting some code I'm writing. > In the process, I stumbled across the following > curiosity: >=20 > > cat test.c > #include > > gcc -std=3Dc99 -ansi test.c > In file included from test.c:1: > /usr/include/stdio.h:220: conflicting types for `restrict' > /usr/include/stdio.h:220: previous declaration of `restrict' > /usr/include/stdio.h:221: conflicting types for `restrict' > /usr/include/stdio.h:221: previous declaration of `restrict' > /usr/include/stdio.h:222: redefinition of `restrict' > /usr/include/stdio.h:222: `restrict' previously declared here > /usr/include/stdio.h:223: conflicting types for `restrict' > [ .... many similar lines omitted .... ] >=20 > If I change all "__restrict" in stdio.h to "__restrict__", > these warnings disappear. >=20 > Question: Does anyone know the difference between > __restrict and __restrict__? >=20 __restrict__ is the gcc(1)-only feature. From gcc.info: : `-std=3D' : Determine the language standard. This option is currently only : supported when compiling C or C++. A value for this option must be : provided; possible values are : [...] : Even when this option is not specified, you can still use some of : the features of newer standards in so far as they do not conflict : with previous C standards. For example, you may use : `__restrict__' even when `-std=3Dc99' is not specified. : [...] : As with gcc, g++ understands the C99 feature of restricted pointers, : specified with the `__restrict__', or `__restrict' type qualifier. : Because you cannot compile C++ by specifying the `-std=3Dc99' language : flag, `restrict' is not a keyword in C++. __restrict is defined in , it's the FreeBSD feature. > Should we be using the latter in our system headers? >=20 No, we should be using the __restrict as coded. But I wonder why we can't just use "restrict", please see below. Note that __restrict is a no-op these days because we don't compile our C code by default with -std=3Dc99. I'm not sure why we can't replace #if !(__GNUC__ =3D=3D 2 && __GNUC_MINOR__ =3D=3D 95) #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 #define __restrict #else #define __restrict restrict #endif #endif with #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 #define restrict #endif and just use "restrict" everywhere. Also similarly I'm not aware of the status of the CSTD feature for share/mk that was backed out. (8 makefiles in src/ still have CSTD.) Cheers, --=20 Ruslan Ermilov FreeBSD committer ru@FreeBSD.org --aznLbwQ42o7LEaqN Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFACJaxUkv4P6juNwoRAs8QAJ4+VXlFcR/iCq0xuCb6dvyABDbLjQCcCP7F IJw2dMYDsvDokd5XAwek8Qw= =/VgN -----END PGP SIGNATURE----- --aznLbwQ42o7LEaqN--