Message ID | 20140518125743.GA11620@domone.podge |
---|---|
State | New |
Headers | show |
On 18 May 2014 13:57, Ondřej Bílka <neleai@seznam.cz> wrote: > Hi, > > As written in bug report: > > " > When <argp.h> is included first and thus __attribute__ is not defined, > with -std=c90, c99 or c11, the __attribute__ is redefined as empty due > to the following code: > This might break headers included later, for example it breaks > -D_FORTIFY_SOURCE=2 by not defining strcpy() correctly [1]. Besides some > reformating, this code is more than 10 years old, and I don't know if > there is still a reason to redefine __attribute__ that way. > " > > So is there any reason to keep fragments of code below? As we use > __attribute__ in stdio.h without checking gcc version I doubt that > compiling with gcc would work. I did not checked that though. I believe this file is shared with gnulib so changes should ideally be synchronized between the two projects. > > > > * argp/argp-fmtstream.h: Do not define __attribute__. > * argp/argp.h: Likewise. > > > diff --git a/argp/argp-fmtstream.h b/argp/argp-fmtstream.h > index 1ed2834..f3f82df 100644 > --- a/argp/argp-fmtstream.h > +++ b/argp/argp-fmtstream.h > @@ -29,21 +29,6 @@ > #include <string.h> > #include <unistd.h> > > -#ifndef __attribute__ > -/* This feature is available in gcc versions 2.5 and later. */ > -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || \ > - defined __STRICT_ANSI__ > -# define __attribute__(Spec) /* empty */ > -# endif > -/* The __-protected variants of `format' and `printf' attributes > - are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ > -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || \ > - defined __STRICT_ANSI__ > -# define __format__ format > -# define __printf__ printf > -# endif > -#endif > - > #if defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H) > /* line_wrap_stream is available, so use that. */ > #define ARGP_FMTSTREAM_USE_LINEWRAP > diff --git a/argp/argp.h b/argp/argp.h > index 0868228..c1072a3 100644 > --- a/argp/argp.h > +++ b/argp/argp.h > @@ -35,21 +35,6 @@ > # define __NTH(fct) fct __THROW > #endif > > -#ifndef __attribute__ > -/* This feature is available in gcc versions 2.5 and later. */ > -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || \ > - defined __STRICT_ANSI__ > -# define __attribute__(Spec) /* empty */ > -# endif > -/* The __-protected variants of `format' and `printf' attributes > - are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ > -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || \ > - defined __STRICT_ANSI__ > -# define __format__ format > -# define __printf__ printf > -# endif > -#endif > - > /* GCC 2.95 and later have "__restrict"; C99 compilers have > "restrict", and "configure" may have defined "restrict". */ > #ifndef __restrict
On Mon, May 19, 2014 at 08:37:27AM +0100, Will Newton wrote: > On 18 May 2014 13:57, Ondřej Bílka <neleai@seznam.cz> wrote: > > Hi, > > > > As written in bug report: > > > > " > > When <argp.h> is included first and thus __attribute__ is not defined, > > with -std=c90, c99 or c11, the __attribute__ is redefined as empty due > > to the following code: > > This might break headers included later, for example it breaks > > -D_FORTIFY_SOURCE=2 by not defining strcpy() correctly [1]. Besides some > > reformating, this code is more than 10 years old, and I don't know if > > there is still a reason to redefine __attribute__ that way. > > " > > > > So is there any reason to keep fragments of code below? As we use > > __attribute__ in stdio.h without checking gcc version I doubt that > > compiling with gcc would work. I did not checked that though. > > I believe this file is shared with gnulib so changes should ideally be > synchronized between the two projects. > CCing gnulib. Could this be backported also there or do you have different solution? > > > > > > > > * argp/argp-fmtstream.h: Do not define __attribute__. > > * argp/argp.h: Likewise. > > > > > > diff --git a/argp/argp-fmtstream.h b/argp/argp-fmtstream.h > > index 1ed2834..f3f82df 100644 > > --- a/argp/argp-fmtstream.h > > +++ b/argp/argp-fmtstream.h > > @@ -29,21 +29,6 @@ > > #include <string.h> > > #include <unistd.h> > > > > -#ifndef __attribute__ > > -/* This feature is available in gcc versions 2.5 and later. */ > > -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || \ > > - defined __STRICT_ANSI__ > > -# define __attribute__(Spec) /* empty */ > > -# endif > > -/* The __-protected variants of `format' and `printf' attributes > > - are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ > > -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || \ > > - defined __STRICT_ANSI__ > > -# define __format__ format > > -# define __printf__ printf > > -# endif > > -#endif > > - > > #if defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H) > > /* line_wrap_stream is available, so use that. */ > > #define ARGP_FMTSTREAM_USE_LINEWRAP > > diff --git a/argp/argp.h b/argp/argp.h > > index 0868228..c1072a3 100644 > > --- a/argp/argp.h > > +++ b/argp/argp.h > > @@ -35,21 +35,6 @@ > > # define __NTH(fct) fct __THROW > > #endif > > > > -#ifndef __attribute__ > > -/* This feature is available in gcc versions 2.5 and later. */ > > -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || \ > > - defined __STRICT_ANSI__ > > -# define __attribute__(Spec) /* empty */ > > -# endif > > -/* The __-protected variants of `format' and `printf' attributes > > - are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ > > -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || \ > > - defined __STRICT_ANSI__ > > -# define __format__ format > > -# define __printf__ printf > > -# endif > > -#endif > > - > > /* GCC 2.95 and later have "__restrict"; C99 compilers have > > "restrict", and "configure" may have defined "restrict". */ > > #ifndef __restrict >
Ondřej Bílka wrote: > CCing gnulib. Could this be backported also there or do you have > different solution? We solved this problem in a different way years ago, using something like this: #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR >= 7) # define _GL_ATTRIBUTE_FORMAT(s) __attribute__ ((__format__ s)) #else # define _GL_ATTRIBUTE_FORMAT(s) #endif and then using _GL_ATTRIBUTE_FORMAT ((__printf__, 2, 3)) later, instead of __attribute__ ((__format__ (__printf__, 2, 3))). Presumably glibc could do something similar. Glibc could use a different name; that's all right, gnulib will just switch to the name that glibc uses.
diff --git a/argp/argp-fmtstream.h b/argp/argp-fmtstream.h index 1ed2834..f3f82df 100644 --- a/argp/argp-fmtstream.h +++ b/argp/argp-fmtstream.h @@ -29,21 +29,6 @@ #include <string.h> #include <unistd.h> -#ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || \ - defined __STRICT_ANSI__ -# define __attribute__(Spec) /* empty */ -# endif -/* The __-protected variants of `format' and `printf' attributes - are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || \ - defined __STRICT_ANSI__ -# define __format__ format -# define __printf__ printf -# endif -#endif - #if defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H) /* line_wrap_stream is available, so use that. */ #define ARGP_FMTSTREAM_USE_LINEWRAP diff --git a/argp/argp.h b/argp/argp.h index 0868228..c1072a3 100644 --- a/argp/argp.h +++ b/argp/argp.h @@ -35,21 +35,6 @@ # define __NTH(fct) fct __THROW #endif -#ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || \ - defined __STRICT_ANSI__ -# define __attribute__(Spec) /* empty */ -# endif -/* The __-protected variants of `format' and `printf' attributes - are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || \ - defined __STRICT_ANSI__ -# define __format__ format -# define __printf__ printf -# endif -#endif - /* GCC 2.95 and later have "__restrict"; C99 compilers have "restrict", and "configure" may have defined "restrict". */ #ifndef __restrict