Discussion:
Fix invalid use of restrict
Alexey Pavlov
2013-11-28 08:03:59 UTC
Permalink
In CVS version I get error: invalid use of restrict. Patch for it is below
From 2a2164e5ed7cf6220ae7b2f7dac3016e1bf9293e Mon Sep 17 00:00:00 2001
From: Alexpux <alexey.pawlow-***@public.gmane.org>
Date: Thu, 28 Nov 2013 12:01:15 +0400
Subject: [PATCH] Fix invalid use of 'restrict' error.

---
winsup/cygwin/include/glob.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/include/glob.h b/winsup/cygwin/include/glob.h
index 4ad200f..59f0efc 100644
--- a/winsup/cygwin/include/glob.h
+++ b/winsup/cygwin/include/glob.h
@@ -103,7 +103,7 @@ __BEGIN_DECLS
# define DLLEXPORT __declspec(dllimport)
#endif

-int DLLEXPORT glob (const char __restrict *, int, int (*)(const char
*, int), glob_t *__restrict);
+int DLLEXPORT glob (const char *__restrict, int, int (*)(const char
*, int), glob_t *__restrict);
void DLLEXPORT globfree (glob_t *);
int DLLEXPORT glob_pattern_p (const char *, int);
__END_DECLS
--
1.8.3.4 (Apple Git-47)
Corinna Vinschen
2013-11-28 10:04:06 UTC
Permalink
Post by Alexey Pavlov
In CVS version I get error: invalid use of restrict. Patch for it is below
Thanks, applied. Why on earth does none of my GCCs throw an error
or warning about this?!?

Btw., next time, please send patches to the cygwin-patches mailing list,
and please add a ChangeLog entry so I don't have to invent one myself.


Thanks,
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
Alexpux
2013-11-28 10:06:04 UTC
Permalink
Post by Corinna Vinschen
Post by Alexey Pavlov
In CVS version I get error: invalid use of restrict. Patch for it is below
Thanks, applied. Why on earth does none of my GCCs throw an error
or warning about this?!?
Because I got this error not on building runtime but when build other program with this headers.

Regards,
Alexey.
Post by Corinna Vinschen
Btw., next time, please send patches to the cygwin-patches mailing list,
and please add a ChangeLog entry so I don't have to invent one myself.
Thanks,
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
Corinna Vinschen
2013-11-28 10:34:32 UTC
Permalink
Post by Alexpux
Post by Corinna Vinschen
Post by Alexey Pavlov
In CVS version I get error: invalid use of restrict. Patch for it is below
Thanks, applied. Why on earth does none of my GCCs throw an error
or warning about this?!?
Because I got this error not on building runtime but when build other program with this headers.
But glob.cc includes glob.h as well. It should have picked up the wrong
definition and ... oh, darn. "restrict" is filtered out in C++ because
it's a C99 keyword. Here's what sys/cdefs.h does:

#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint)
#define __restrict
#else
#define __restrict restrict
#endif
#endif

__STDC_VERSION__ is not defined when building C++ files.

However, G++ knows the __restrict and __restrict__ keyword, so I wonder
if we shouldn't enable __restrict when building C++ with g++. I guess
I'll discuss this on the newlib list.


Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
Corinna Vinschen
2013-11-28 10:51:05 UTC
Permalink
Post by Corinna Vinschen
Post by Alexpux
Post by Corinna Vinschen
Post by Alexey Pavlov
In CVS version I get error: invalid use of restrict. Patch for it is below
Thanks, applied. Why on earth does none of my GCCs throw an error
or warning about this?!?
Because I got this error not on building runtime but when build other program with this headers.
But glob.cc includes glob.h as well. It should have picked up the wrong
definition and ... oh, darn. "restrict" is filtered out in C++ because
#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint)
#define __restrict
#else
#define __restrict restrict
#endif
#endif
__STDC_VERSION__ is not defined when building C++ files.
However, G++ knows the __restrict and __restrict__ keyword, so I wonder
if we shouldn't enable __restrict when building C++ with g++. I guess
I'll discuss this on the newlib list.
Uh, never mind. In glibc headers it's not defined for C++ either.


Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
Loading...