The restrict keyword in not standard in C++. In g++, __restrict or __restrict__ can be used. But I don't understand which. I found code examples using __restrict and others using __restrict__. Which one should I use in my C++ code? And if I want some of my code to be C-compatible, should I use a #define which will allow me two switch to restrict if C-compatibility is enabled?
This way if there's a problem with __restrict__ or restrict or __restrict, or whatever, you can just change the #define to get it to compile, rather than ransack your code.
Actually it doesn't have to be ugly: replace RESTRICT with restrict. The question is whether __restrict or __restrict__ should be used in g++.
(restrict IS a "C thing" and is non-standard in C++, but since it's as beneficial in C++ as it is in C, I don't see why not use it in C++ code too)
(By the way, RESTRICT int* foo should be int *RESTRICT foo. If I'm not mistaken)
And yes, compilers do take advantage of it. If I'm not mistaken (maybe I am!), restric is less useful with x86 processors than with Sun's and Apple's ones (in terms of performance gain), but its use whenever possible is still reccomended.
It justs exists to assist with alias optimisation issues. It's not a big deal, other than to stop you making up aliases. C compilers have coped with it for 20+ years now without it.