Skip to content

Commit 885142a

Browse files
bnoordhuisindutny
authored andcommitted
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>
1 parent 9287550 commit 885142a

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/node_constants.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,28 @@
1919
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

22+
// O_NONBLOCK is not exported unless _XOPEN_SOURCE >= 500.
23+
#if defined(_XOPEN_SOURCE) && _XOPEN_SOURCE < 500
24+
#undef _XOPEN_SOURCE
25+
#endif
26+
27+
#if !defined(_XOPEN_SOURCE)
28+
#define _XOPEN_SOURCE 500
29+
#endif
30+
2231
#include "node_constants.h"
2332

2433
#include "uv.h"
2534

2635
#include <errno.h>
36+
#include <fcntl.h>
2737
#if !defined(_MSC_VER)
2838
#include <unistd.h>
2939
#endif
3040
#include <signal.h>
3141
#include <sys/types.h>
3242
#include <sys/stat.h>
3343

34-
// O_NONBLOCK is not exported, unless _XOPEN_SOURCE is set
35-
#define _XOPEN_SOURCE 500
36-
#include <fcntl.h>
37-
3844
#if HAVE_OPENSSL
3945
# include <openssl/ssl.h>
4046
#endif

0 commit comments

Comments
 (0)