Re: newlib header breaks restricted pointers in C++
Corinna Vinschen <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <ZMIyGF/[email protected]> |
On Jul 25 19:48, Steven J Abner wrote:
> Curiosity killed the cat,
> I might not understand, could you clarify. It mentions 'restrict is not a
> keyword in C++'.
> So doesn't #if __cpplusplus need to define 'restrict'. Additionally,
> shouldn't the below mentioned
> '#define'(s) include '__restrict__ ?
I don't think the header should really define "restrict" for C++,
it would clobber the namespace.
We have the following scenario:
- GCC defines __restrict (and __restrict__) for C and C++.
- Newlib overloads __restrict for all GCC versions != 2.95.
- Either to nothing, if the app standard is < C99, or
- to "restrict" if the app standard is >= C99.
The negated release check for version 2.95 exactly is certainly fishy.
Let's compare with the GLibc version:
/* __restrict is known in EGCS 1.2 and above, and in clang.
It works also in C++ mode (outside of arrays), but only when spelled
as '__restrict', not 'restrict'. */
#if !(__GNUC_PREREQ (2,92) || __clang_major__ >= 3)
# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
# define __restrict restrict
# else
# define __restrict /* Ignore */
# endif
#endif
So the expression is the same, just the version check makes more sense.
Shall we match our version expression to the GLibc expression?
Corinna