curl-library
[PATCH curl] headers: surround GCC attribute names with double underscores
From: Jonathan Nieder <jrnieder_at_gmail.com>
Date: Fri, 13 Apr 2012 19:30:23 -0500
Date: Fri, 13 Apr 2012 19:30:23 -0500
Without this change, a project that defines warning(x) or unused as a
macro for its own use before including <curl/curl.h> can get warnings
like this:
/usr/include/curl/typecheck-gcc.h:147:1: error: expected ‘)’ before ‘(’ token
/usr/include/curl/typecheck-gcc.h:147:1: error: expected identifier or ‘(’ before ‘)’ token
/usr/include/curl/typecheck-gcc.h:149:1: error: expected ‘)’ before ‘(’ token
...
GCC has supported the attribute names with surrounding __ since
1994 (r8412, "Check for attributes with leading and trailing double
underscores"), so this shouldn't hurt portability.
---
Based on a true story. Thoughts?
Thanks for keeping curl working nicely.
Sincerely,
Jonathan
include/curl/typecheck-gcc.h | 5 +++--
lib/setup.h | 2 +-
m4/curl-compilers.m4 | 6 +++---
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/include/curl/typecheck-gcc.h b/include/curl/typecheck-gcc.h
index 5c584b00..6f81f69e 100644
--- a/include/curl/typecheck-gcc.h
+++ b/include/curl/typecheck-gcc.h
@@ -141,8 +141,9 @@ __extension__ ({ \
/* To define a new warning, use _CURL_WARNING(identifier, "message") */
#define _CURL_WARNING(id, message) \
- static void __attribute__((warning(message))) __attribute__((unused)) \
- __attribute__((noinline)) id(void) { __asm__(""); }
+ static void __attribute__((__warning__(message))) \
+ __attribute__((__unused__)) __attribute__((__noinline__)) id(void) \
+ { __asm__(""); }
_CURL_WARNING(_curl_easy_setopt_err_long,
"curl_easy_setopt expects a long argument for this option")
diff --git a/lib/setup.h b/lib/setup.h
index 6ce93db4..4bce5a93 100644
--- a/lib/setup.h
+++ b/lib/setup.h
@@ -611,7 +611,7 @@ int netware_init(void);
#ifndef __GNUC__
#define UNUSED_PARAM /*NOTHING*/
#else
-#define UNUSED_PARAM __attribute__((unused))
+#define UNUSED_PARAM __attribute__((__unused__))
#endif
/*
diff --git a/m4/curl-compilers.m4 b/m4/curl-compilers.m4
index 9b212e46..2de33d55 100644
--- a/m4/curl-compilers.m4
+++ b/m4/curl-compilers.m4
@@ -1393,7 +1393,7 @@ AC_DEFUN([CURL_CHECK_COMPILER_SYMBOL_HIDING], [
case "$compiler_id" in
CLANG)
dnl All versions of clang support -fvisibility=
- tmp_EXTERN="__attribute__ ((visibility (\"default\")))"
+ tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
tmp_CFLAGS="-fvisibility=hidden"
supports_symbol_hiding="yes"
;;
@@ -1401,7 +1401,7 @@ AC_DEFUN([CURL_CHECK_COMPILER_SYMBOL_HIDING], [
dnl Only gcc 3.4 or later
if test "$compiler_num" -ge "304"; then
if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then
- tmp_EXTERN="__attribute__ ((visibility (\"default\")))"
+ tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
tmp_CFLAGS="-fvisibility=hidden"
supports_symbol_hiding="yes"
fi
@@ -1420,7 +1420,7 @@ AC_DEFUN([CURL_CHECK_COMPILER_SYMBOL_HIDING], [
printf("icc fvisibility bug test");
]])
],[
- tmp_EXTERN="__attribute__ ((visibility (\"default\")))"
+ tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
tmp_CFLAGS="-fvisibility=hidden"
supports_symbol_hiding="yes"
])
--
1.7.10
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-04-14