From 7003d6eff56193aa6f2370cafb7f7bf10db243c7 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 23 Aug 2011 18:26:39 +0200 Subject: [PATCH] Move ARRAY_SIZE macro to node.h --- src/node.cc | 2 -- src/node.h | 4 ++++ src/node_file.cc | 1 - src/node_net.cc | 2 -- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/node.cc b/src/node.cc index ec5f4353b8..5818520934 100644 --- a/src/node.cc +++ b/src/node.cc @@ -100,8 +100,6 @@ extern "C" { #include #include -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) - using namespace v8; # ifdef __APPLE__ diff --git a/src/node.h b/src/node.h index 9e816e0c7c..851f0f6107 100644 --- a/src/node.h +++ b/src/node.h @@ -46,6 +46,10 @@ #include +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0])) +#endif + #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n) #define NODE_STRINGIFY_HELPER(n) #n diff --git a/src/node_file.cc b/src/node_file.cc index 51c569f2ca..aa751fb613 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -69,7 +69,6 @@ namespace node { using namespace v8; -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) #define MIN(a,b) ((a) < (b) ? (a) : (b)) #define THROW_BAD_ARGS \ ThrowException(Exception::TypeError(String::New("Bad argument"))) diff --git a/src/node_net.cc b/src/node_net.cc index d060e9b3d3..3b6fe389e5 100644 --- a/src/node_net.cc +++ b/src/node_net.cc @@ -83,8 +83,6 @@ # define SHUT_RDWR SD_BOTH #endif -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) - namespace node {