[Developers] how to use CCTK_RESTRICT

Erik Schnetter schnetter at cct.lsu.edu
Fri Oct 7 11:01:22 CDT 2005


On Oct 7, 2005, at 10:46:35, Thomas Radke wrote:
> I just learned from Jonathan that the "restrict" keyword is there  
> in the C99 standard, not (necessarily?) in earlier versions.

Correct.

> Are you suggesting to generally use "restrict" when writing Cactus  
> C/C++ code, and then rely on cctk_Config.h to do the right thing ?  
> Then we should rename "CCTK_RESTRICT" into some Cactus internal  
> macro name such as "CCTKi_RESTRICT", shouldn't we ?
> Or should we rather use "CCTK_RESTRICT" in which case the logic in  
> cctk_Config.h (and in your patch) could be simplified ?

Only for C, not for C++.

That is at least what Cactus currently does.  For C code, it #defines  
restrict to do the right thing, i.e., it is either undefined (so that  
"restrict" stays "restrict"), or defined to __restrict__ or some  
other compiler-internal value, or defined to be empty if the compiler  
does not support it at all.  Of course, CCTK_RESTRICT works also for  
C, but it is much less readable.

It is not standard for C++, and Cactus doesn't do anything with  
"restrict" in C++.  You must either use CCTK_RESTRICT, or you can  
#define "restrict" in your code, depending on CCTK_RESTRICT, if you  
prefer that.

In header files that may be included by both C or C++, you also have  
to use CCTK_RESTRICT.

-erik

-- 
Erik Schnetter <schnetter at cct.lsu.edu>

My email is as private as my paper mail.  I therefore support encrypting
and signing email messages.  Get my PGP key from www.keyserver.net.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://www.cactuscode.org/pipermail/developers/attachments/20051007/e473d470/attachment.bin 


More information about the Developers mailing list