[Gegl-developer] #defining the restrict keyword

Nicolas Robidoux nrobidoux at cs.laurentian.ca
Sat Sep 13 08:21:18 PDT 2008


Hello Sven:

Given that the restrict keyword may be defined by default for other compilers than gcc (it is in gcc 

http://developer.apple.com/documentation/DeveloperTools/gcc-4.0.1/gcc/Other-Builtins.html

wouldn't the following be better?

#ifndef restrict
#ifndef G_GNUC_RESTRICT
#if defined (__GNUC__) && (__GNUC__ >= 4)
#define G_GNUC_RESTRICT __restrict__
#else
#define G_GNUC_RESTRICT
#endif
#define restrict G_GNUC_RESTRICT
#endif
#endif

This appears to work in (the not yet patched in svn) yafr. 

------

Even better:

It appears that autoconf can take care of this in one fell swoop:

http://www.gnu.org/software/libtool/manual/autoconf/C-Compiler.html

See the Macro: AC_C_RESTRICT section.

Nicolas Robidoux
Laurentian University/Universite Laurentienne



More information about the Gegl-developer mailing list