From: Ben Noordhuis Date: Tue, 13 May 2014 11:45:21 +0000 (+0200) Subject: src: fix _XOPEN_SOURCE redefinition warning X-Git-Tag: v0.10.29~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=885142a5edc2c803fa8b9d92b5d0771379237764;p=platform%2Fupstream%2Fnodejs.git 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 expose O_NONBLOCK but it does so after other system headers have been included. If those headers include , then the #include in node_constants.cc will be a no-op and O_NONBLOCK won't be visible. Signed-off-by: Fedor Indutny --- diff --git a/src/node_constants.cc b/src/node_constants.cc index d364fb2..adb6f28 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 +#include #if !defined(_MSC_VER) #include #endif @@ -31,10 +41,6 @@ #include #include -// O_NONBLOCK is not exported, unless _XOPEN_SOURCE is set -#define _XOPEN_SOURCE 500 -#include - #if HAVE_OPENSSL # include #endif