Skip to content

Commit e1fe270

Browse files
committed
src: prefix ARCH and PLATFORM with NODE_
The PLATFORM preprocessor symbol is defined in node.gyp, and on Windows it's set to "win". This conflicts with a built-in preprocessor symbol with a different value ("win32"), which makes the linker(!) complain. Resolve this by renaming these symbols to NODE_ARCH and NODE_PLATFORM. PR-URL: #261 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 858b558 commit e1fe270

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

node.gyp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@
164164
],
165165

166166
'defines': [
167-
'NODE_WANT_INTERNALS=1',
168-
'ARCH="<(target_arch)"',
169-
'PLATFORM="<(OS)"',
167+
'NODE_ARCH="<(target_arch)"',
168+
'NODE_PLATFORM="<(OS)"',
170169
'NODE_TAG="<(node_tag)"',
171170
'NODE_V8_OPTIONS="<(node_v8_options)"',
171+
'NODE_WANT_INTERNALS=1',
172172
],
173173

174174
'conditions': [

src/node.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2623,12 +2623,17 @@ void SetupProcessObject(Environment* env,
26232623
#endif
26242624

26252625
// process.arch
2626-
READONLY_PROPERTY(process, "arch", OneByteString(env->isolate(), ARCH));
2626+
READONLY_PROPERTY(process, "arch", OneByteString(env->isolate(), NODE_ARCH));
26272627

26282628
// process.platform
2629-
READONLY_PROPERTY(process,
2630-
"platform",
2631-
OneByteString(env->isolate(), PLATFORM));
2629+
#ifdef _WIN32
2630+
// As determined by gyp, NODE_PLATFORM equals 'win' on windows. However
2631+
// for historic reasons process.platform should be 'win32'.
2632+
Local<String> platform = OneByteString(env->isolate(), "win32");
2633+
#else
2634+
Local<String> platform = OneByteString(env->isolate(), NODE_PLATFORM);
2635+
#endif
2636+
READONLY_PROPERTY(process, "platform", platform);
26322637

26332638
// process.argv
26342639
Local<Array> arguments = Array::New(env->isolate(), argc);

0 commit comments

Comments
 (0)