Skip to content

Commit 742efa6

Browse files
committed
src: fix ssize_t error from nghttp2.h
The "node_http2.h" include reordering enforced by clang-format broke Electron's Node.js upgrade on Windows. ssize_t is a part of the POSIX standard and it's not available on Windows, so the fix for this is to typedef it on Windows like in https://github.com/nodejs/node/blob/bb4dff783ddb3b20c67041f7ccef796c335c2407/src/node.h#L212-L220. Refs: electron/electron#35350 (comment) Signed-off-by: Darshan Sen <[email protected]>
1 parent 937520a commit 742efa6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/node_http2.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@
55

66
// FIXME(joyeecheung): nghttp2.h needs stdint.h to compile on Windows
77
#include <cstdint>
8+
9+
// nghttp2.h needs ssize_t to compile on Windows.
10+
// Refs: https://github.com/electron/electron/pull/35350#discussion_r954890551
11+
// Same as
12+
// https://github.com/nodejs/node/blob/bb4dff783ddb3b20c67041f7ccef796c335c2407/src/node.h#L212-L220.
13+
#ifdef _WIN32
14+
#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
15+
typedef intptr_t ssize_t;
16+
#define _SSIZE_T_
17+
#define _SSIZE_T_DEFINED
18+
#endif
19+
#else // !_WIN32
20+
#include <sys/types.h> // size_t, ssize_t
21+
#endif // _WIN32
22+
823
#include "nghttp2/nghttp2.h"
924

1025
#include "env.h"

0 commit comments

Comments
 (0)