Skip to content

Commit b884430

Browse files
committed
fix: reorder includes for Windows compatibility and add missing POSIX headers
1 parent c03162b commit b884430

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

src/tcp_wrap.cc

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

22-
#include "tcp_wrap.h"
22+
#include "tcp_wrap.h" // 1. Implementation header first
23+
24+
// 2. Windows System Headers (MUST BE BEFORE Node.js internals)
25+
#ifdef _WIN32
26+
#include <winsock2.h>
27+
#include <ws2tcpip.h>
28+
#endif
29+
30+
// 3. Node.js Internal Headers
2331
#include "connect_wrap.h"
2432
#include "connection_wrap.h"
2533
#include "env-inl.h"
@@ -31,13 +39,15 @@
3139
#include "stream_base-inl.h"
3240
#include "stream_wrap.h"
3341
#include "util-inl.h"
42+
43+
// 4. Standard C++ & POSIX Headers
3444
#include <cerrno>
3545
#include <cstdlib>
36-
#ifdef _WIN32
37-
#include <ws2tcpip.h>
38-
#endif
46+
3947
#ifndef _WIN32
40-
#include <netinet/in.h>
48+
#include <netinet/in.h> // Required for IPPROTO_IP
49+
#include <netinet/ip.h> // Required for IP_TOS
50+
#include <netinet/ip6.h> // Required for IPV6_TCLASS
4151
#include <sys/socket.h>
4252
#endif
4353

0 commit comments

Comments
 (0)