diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2015-05-05 18:17:55 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2015-05-05 18:50:47 +0200 |
commit | b712af79a719b79e9c060bf4df54571e11870914 (patch) | |
tree | 603dad67e4b8349e4ba604274f973a864be76aa2 /src/node.h | |
parent | 71dc7152eee93c70ab1a078b07c620e6d67c97fe (diff) | |
download | node-new-b712af79a719b79e9c060bf4df54571e11870914.tar.gz |
src: fix NODE_DEPRECATED macro with old compilers
The `__attribute__((deprecated("warning")))` macro didn't exist until
gcc 4.5 and clang 2.9.
While io.js does not build with compilers that old, add-ons do. Let's
make src/node.h compatible with such compilers, it's a public header.
PR-URL: https://github.com/iojs/io.js/pull/1626
Refs: https://github.com/iojs/io.js/issues/1619
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'src/node.h')
-rw-r--r-- | src/node.h | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/node.h b/src/node.h index 5962c32d5b..9556285a55 100644 --- a/src/node.h +++ b/src/node.h @@ -42,14 +42,33 @@ #include "v8.h" // NOLINT(build/include_order) #include "node_version.h" // NODE_MODULE_VERSION -#if defined(__GNUC__) -# define NODE_DEPRECATED(message, declarator) \ +#define IOJS_MAKE_VERSION(major, minor, patch) \ + ((major) * 0x1000 + (minor) * 0x100 + (patch)) + +#ifdef __clang__ +# define IOJS_CLANG_AT_LEAST(major, minor, patch) \ + (IOJS_MAKE_VERSION(major, minor, patch) <= \ + IOJS_MAKE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)) +#else +# define IOJS_CLANG_AT_LEAST(major, minor, patch) (0) +#endif + +#ifdef __GNUC__ +# define IOJS_GNUC_AT_LEAST(major, minor, patch) \ + (IOJS_MAKE_VERSION(major, minor, patch) <= \ + IOJS_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)) +#else +# define IOJS_GNUC_AT_LEAST(major, minor, patch) (0) +#endif + +#if IOJS_CLANG_AT_LEAST(2, 9, 0) || IOJS_GNUC_AT_LEAST(4, 5, 0) +# define NODE_DEPRECATED(message, declarator) \ __attribute__((deprecated(message))) declarator #elif defined(_MSC_VER) -# define NODE_DEPRECATED(message, declarator) \ +# define NODE_DEPRECATED(message, declarator) \ __declspec(deprecated) declarator #else -# define NODE_DEPRECATED(message, declarator) \ +# define NODE_DEPRECATED(message, declarator) \ declarator #endif |