diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2014-05-13 13:45:21 +0200 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2014-05-14 15:33:18 +0400 |
commit | 885142a5edc2c803fa8b9d92b5d0771379237764 (patch) | |
tree | f8564d9ee0f35d38765608b7263003000f72c458 /src | |
parent | 92875501d23c187c490a7f5ead454e1891b27aa1 (diff) | |
download | node-885142a5edc2c803fa8b9d92b5d0771379237764.tar.gz |
src: fix _XOPEN_SOURCE redefinition warning
Fix the following compiler warning on systems where _XOPEN_SOURCE is
defined by default:
../src/node_constants.cc:35:0: warning: "_XOPEN_SOURCE" redefined
#define _XOPEN_SOURCE 500
Move the (re)definition of _XOPEN_SOURCE to the top of the file while
we're here. Commit 00890e4 adds a `#define _XOPEN_SOURCE 500` in order
to make <fcntl.h> expose O_NONBLOCK but it does so after other system
headers have been included. If those headers include <fcntl.h>, then
the #include in node_constants.cc will be a no-op and O_NONBLOCK won't
be visible.
Signed-off-by: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/node_constants.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/node_constants.cc b/src/node_constants.cc index d364fb2df..adb6f2818 100644 --- a/src/node_constants.cc +++ b/src/node_constants.cc @@ -19,11 +19,21 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +// O_NONBLOCK is not exported unless _XOPEN_SOURCE >= 500. +#if defined(_XOPEN_SOURCE) && _XOPEN_SOURCE < 500 +#undef _XOPEN_SOURCE +#endif + +#if !defined(_XOPEN_SOURCE) +#define _XOPEN_SOURCE 500 +#endif + #include "node_constants.h" #include "uv.h" #include <errno.h> +#include <fcntl.h> #if !defined(_MSC_VER) #include <unistd.h> #endif @@ -31,10 +41,6 @@ #include <sys/types.h> #include <sys/stat.h> -// O_NONBLOCK is not exported, unless _XOPEN_SOURCE is set -#define _XOPEN_SOURCE 500 -#include <fcntl.h> - #if HAVE_OPENSSL # include <openssl/ssl.h> #endif |