From: Ivan Maidanski Date: Wed, 20 Jun 2018 07:36:25 +0000 (+0300) Subject: Do not include windows.h when compiling gc_cpp.cc X-Git-Tag: v8.0.0~106 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=466976e79a437b9a6addaf0b9ffe2689e568ae79;p=gc Do not include windows.h when compiling gc_cpp.cc (code refactoring) * gc_cpp.cc (GC_DONT_INCL_WINDOWS_H): Define macro before include gc.h. * tests/test_cpp.cc (GC_DONT_INCL_WINDOWS_H): Likewise. * include/gc.h [GC_WIN32_THREADS && (!GC_PTHREADS || GC_BUILD || GC_WINDOWS_H_INCLUDED) && (!GC_NO_THREAD_DECLS || GC_BUILD)]: If GC_DONT_INCL_WINDOWS_H then do not include process.h, windows.h, and do not declare GC_CreateThread, GC_ExitThread, GC_DllMain, GC_beginthreadex, GC_endthreadex. --- diff --git a/gc_cpp.cc b/gc_cpp.cc index 88ffe96e..baf8ca49 100644 --- a/gc_cpp.cc +++ b/gc_cpp.cc @@ -27,6 +27,7 @@ built-in "new" and "delete". # define GC_BUILD #endif +#define GC_DONT_INCL_WINDOWS_H #include "gc.h" #include // for bad_alloc, precedes include of gc_cpp.h diff --git a/include/gc.h b/include/gc.h index 0f5d8435..e43f7f75 100644 --- a/include/gc.h +++ b/include/gc.h @@ -1688,7 +1688,8 @@ GC_API void GC_CALL GC_register_has_static_roots_callback( /* Note: for Cygwin and pthreads-win32, this is skipped */ /* unless windows.h is included before gc.h. */ -# if !defined(GC_NO_THREAD_DECLS) || defined(GC_BUILD) +# if (!defined(GC_NO_THREAD_DECLS) || defined(GC_BUILD)) \ + && !defined(GC_DONT_INCL_WINDOWS_H) # ifdef __cplusplus } /* Including windows.h in an extern "C" context no longer works. */ diff --git a/tests/test_cpp.cc b/tests/test_cpp.cc index 669bf782..493ec33d 100644 --- a/tests/test_cpp.cc +++ b/tests/test_cpp.cc @@ -28,6 +28,7 @@ few minutes to complete. #undef GC_BUILD +#define GC_DONT_INCL_WINDOWS_H #include "gc_cpp.h" #include