Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Feb 2004 22:19:40 +0100
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        Bill Moran <wmoran@potentialtech.com>
Cc:        FreeBSD-Questions <FreeBSD-Questions@FreeBSD.org>
Subject:   Re: What does __restrict do?
Message-ID:  <20040210211940.GA93312@falcon.midgard.homeip.net>
In-Reply-To: <4029329E.1070406@potentialtech.com>
References:  <4029329E.1070406@potentialtech.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Feb 10, 2004 at 02:35:58PM -0500, Bill Moran wrote:
> In various places in the source code, for example, in the code for printf():
> 
> printf(char const * __restrict fmt, ...)
> 
> I understand everything except __restrict.  What does that mean/do?  Is it
> a FreeBSDism?  (I can't find anything about it in any C docs)

'__restrict' is a macro that expands to either 'restrict' if the
compiler used supports that keyword, or to the empty string otherwise.

'restrict' is a standard C keyword since 1999, and is essentially used
to inform the compiler that two pointers don't alias each other and
that the compiler is therefore free to perform certain optimizations
that otherwise might not be legal.
It is just a hint to the compiler, and can always be removed (but not
necessarily added) without changing the semantics of a program.

Any C book that covers C99 should contain a more complete explanation.


-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040210211940.GA93312>