summaryrefslogtreecommitdiff
path: root/funcattrs.h
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-08-19 11:25:24 -0700
committerGuy Harris <guy@alum.mit.edu>2017-08-19 11:25:24 -0700
commit3dc736d939536bcd843597cb655fcba28268705c (patch)
tree6c69e8113f12d847aa00e1c56df66c5777a43137 /funcattrs.h
parent297bf6343f27ea1d18e5dad529c253ffd3935d41 (diff)
downloadtcpdump-3dc736d939536bcd843597cb655fcba28268705c.tar.gz
Handle attributes for function pointers by checking the compiler version.
Handle attributes for function pointers the same way we handle attributes for functions, by explicitly checking for the compiler version with #if rather than with a configure script check. That's one fewer thing that, if you're not using autoconf, has to be done in some other fashion. While we're at it, put NORETURN in the right place to have it work with Microsoft Visual Studio as well as various UN*X compilers.
Diffstat (limited to 'funcattrs.h')
-rw-r--r--funcattrs.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/funcattrs.h b/funcattrs.h
index 63d3f565..bea98634 100644
--- a/funcattrs.h
+++ b/funcattrs.h
@@ -76,13 +76,25 @@
* HP aCC A.06.10 and later.
*/
#define NORETURN __attribute((noreturn))
+
+ /*
+ * However, GCC didn't support that for function *pointers* until GCC
+ * 4.1.0; see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3481.
+ */
+ #if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) < 401))
+ #define NORETURN_FUNCPTR
+ #else
+ #define NORETURN_FUNCPTR __attribute((noreturn))
+ #endif
#elif defined(_MSC_VER)
/*
* MSVC.
*/
#define NORETURN __declspec(noreturn)
+ #define NORETURN_FUNCPTR __declspec(noreturn)
#else
#define NORETURN
+ #define NORETURN_FUNCPTR
#endif
/*
@@ -101,8 +113,19 @@
* or HP aCC A.06.10 and later.
*/
#define PRINTFLIKE(x,y) __attribute__((__format__(__printf__,x,y)))
+
+ /*
+ * However, GCC didn't support that for function *pointers* until GCC
+ * 4.1.0; see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3481.
+ */
+ #if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) < 401))
+ #define PRINTFLIKE_FUNCPTR(x,y)
+ #else
+ #define PRINTFLIKE_FUNCPTR(x,y) __attribute__((__format__(__printf__,x,y)))
+ #endif
#else
#define PRINTFLIKE(x,y)
+ #define PRINTFLIKE_FUNCPTR(x,y)
#endif
/*