This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Small issue with clang & stdlib.h
- From: Emmanuel Blot <eblot dot ml at gmail dot com>
- To: newlib at sourceware dot org
- Date: Wed, 19 Jun 2013 18:53:56 +0200
- Subject: Small issue with clang & stdlib.h
Hi,
I'm using newlib along with the clang compiler (3.4dev).
There is one small issue with newlib (2.0.0): stdlib.h use an
attribute specifier which is not supported with clang: __warning__
All __attribute__ facilities here seem to be supported, but this one.
A simple workaround is to define an intermediate attribute for both
GCC and clang (see patch below), but I guess a cleaner solution would
be to define a dedicated "_DEPRECATED(message)" macro to abstract the
__attribute__ altogether.
HTH,
Manu.
--- a/include/stdlib.h 2013-06-12 15:37:10.000000000 +0200
+++ b/include/stdlib.h 2013-06-12 15:41:10.000000000 +0200
@@ -25,6 +25,12 @@
#include <cygwin/stdlib.h>
#endif
+#ifdef __clang__
+#define _attr_deprecated deprecated
+#else
+#define _attr_deprecated __warning__
+#endif
+
_BEGIN_STD_C
typedef struct
@@ -104,14 +110,14 @@
int _EXFUN(mkostemps,(char *, int, int));
int _EXFUN(mkstemp,(char *));
int _EXFUN(mkstemps,(char *, int));
-char * _EXFUN(mktemp,(char *) _ATTRIBUTE ((__warning__ ("the use of
`mktemp' is dangerous; use `mkstemp' instead"))));
+char * _EXFUN(mktemp,(char *) _ATTRIBUTE ((_attr_deprecated ("the
use of `mktemp' is dangerous; use `mkstemp' instead"))));
#endif
char * _EXFUN(_mkdtemp_r, (struct _reent *, char *));
int _EXFUN(_mkostemp_r, (struct _reent *, char *, int));
int _EXFUN(_mkostemps_r, (struct _reent *, char *, int, int));
int _EXFUN(_mkstemp_r, (struct _reent *, char *));
int _EXFUN(_mkstemps_r, (struct _reent *, char *, int));
-char * _EXFUN(_mktemp_r, (struct _reent *, char *) _ATTRIBUTE
((__warning__ ("the use of `mktemp' is dangerous; use `mkstemp'
instead"))));
+char * _EXFUN(_mktemp_r, (struct _reent *, char *) _ATTRIBUTE
((_attr_deprecated ("the use of `mktemp' is dangerous; use `mkstemp'
instead"))));
#endif
_VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size,
int(*_compar)(const _PTR, const _PTR)));
int _EXFUN(rand,(_VOID));