]> granicus.if.org Git - gc/commitdiff
Do not include windows.h when compiling gc_cpp.cc
authorIvan Maidanski <ivmai@mail.ru>
Wed, 20 Jun 2018 07:36:25 +0000 (10:36 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 20 Jun 2018 07:36:25 +0000 (10:36 +0300)
(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.

gc_cpp.cc
include/gc.h
tests/test_cpp.cc

index 88ffe96eb107e7a735468cfe29770fd4054efb5f..baf8ca4986780a66ff70e7e285d84176d87910a2 100644 (file)
--- 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 <new> // for bad_alloc, precedes include of gc_cpp.h
index 0f5d8435569e0c0a2bb2563aae2963a447cd184e..e43f7f758db6333d38df2a934d4f3567154758bd 100644 (file)
@@ -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. */
index 669bf782adec9e9c69028db59643a371f5ffc89b..493ec33d7f45ba52b356c83c7eb02e9b3c467566 100644 (file)
@@ -28,6 +28,7 @@ few minutes to complete.
 
 #undef GC_BUILD
 
+#define GC_DONT_INCL_WINDOWS_H
 #include "gc_cpp.h"
 
 #include <stdio.h>