Re: #defining the restrict keyword

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello:

Sven Neumann writes:
 > Hi,
 > 
 > On Sat, 2008-09-13 at 11:21 -0400, Nicolas Robidoux wrote:
 > 
 > > 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
 > 
 > Well, using plain "restrict" probably only works if C99 is enabled. And
 > if C99 is enabled, then there's no need for this macro. So the easiest
 > solution would certainly be to switch to C99 for GEGL.
 > 
 > 
 > Sven
 > 
 > 

I believe that restrict is understood by gcc UNLESS told not to (for
example, with -ansi -pedantic). For example, if I put it in
gegl-sampler-yafr.c without otherwise changing the make files, the
code compiles no problem (whether gcc does something useful with it is
another story).

In any case, the above macro will work with any compiler which does
support the restrict keyword in whatever mode it is used (c99 ir not).
In addition, it does not rely on B_GNUC_RESTRICT being defined to
activate "restrict."

Of course, switching to c99 makes this whole discussion irrelevant.

Nicolas Robidoux
Laurentian University/Universite Laurentienne

_______________________________________________
Gegl-developer mailing list
Gegl-developer@xxxxxxxxxxxxxxxxxxxxxx
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gegl-developer

[Index of Archives]     [Yosemite News]     [Yosemite Photos]     [gtk]     [GIMP Users]     [KDE]     [Gimp's Home]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux