From: Ivan Maidanski Date: Sat, 22 Oct 2016 14:39:36 +0000 (+0300) Subject: Workaround 'value of WINAPI unknown' cppcheck info messages X-Git-Tag: v7.6.2~352 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=781f22fc058563af6aa46432540c148a66168ee3;p=gc Workaround 'value of WINAPI unknown' cppcheck info messages * include/gc.h [GC_WIN32_THREADS && WINAPI && !CPPCHECK] (GC_WINDOWS_H_INCLUDED): New macro. * include/gc.h [GC_WIN32_THREADS] (GC_WINDOWS_H_INCLUDED): Define also if windows.h included. * include/gc.h [GC_WIN32_THREADS]: Replace "#ifdef WINAPI" with "#ifdef GC_WINDOWS_H_INCLUDED". --- diff --git a/include/gc.h b/include/gc.h index ab2bc3ac..aef693ee 100644 --- a/include/gc.h +++ b/include/gc.h @@ -1603,8 +1603,14 @@ typedef int (GC_CALLBACK * GC_has_static_roots_func)( GC_API void GC_CALL GC_register_has_static_roots_callback( GC_has_static_roots_func); +#if !defined(CPPCHECK) && !defined(GC_WINDOWS_H_INCLUDED) && defined(WINAPI) + /* windows.h is included before gc.h */ +# define GC_WINDOWS_H_INCLUDED +#endif + #if defined(GC_WIN32_THREADS) \ - && (!defined(GC_PTHREADS) || defined(GC_BUILD) || defined(WINAPI)) + && (!defined(GC_PTHREADS) || defined(GC_BUILD) \ + || defined(GC_WINDOWS_H_INCLUDED)) /* Note: for Cygwin and pthreads-win32, this is skipped */ /* unless windows.h is included before gc.h. */ @@ -1620,6 +1626,7 @@ GC_API void GC_CALL GC_register_has_static_roots_callback( # if defined(GC_BUILD) || !defined(GC_DONT_INCLUDE_WINDOWS_H) # include +# define GC_WINDOWS_H_INCLUDED # endif # ifdef __cplusplus @@ -1635,7 +1642,7 @@ GC_API void GC_CALL GC_register_has_static_roots_callback( # ifndef DECLSPEC_NORETURN /* Typically defined in winnt.h. */ -# if defined(WINAPI) +# ifdef GC_WINDOWS_H_INCLUDED # define DECLSPEC_NORETURN /* empty */ # else # define DECLSPEC_NORETURN __declspec(noreturn) @@ -1651,7 +1658,7 @@ GC_API void GC_CALL GC_register_has_static_roots_callback( # ifdef _WIN64 # define GC_WIN32_SIZE_T GC_uintptr_t -# elif defined(WINAPI) /* windows.h included */ +# elif defined(GC_WINDOWS_H_INCLUDED) # define GC_WIN32_SIZE_T DWORD # else # define GC_WIN32_SIZE_T unsigned long @@ -1662,7 +1669,7 @@ GC_API void GC_CALL GC_register_has_static_roots_callback( # ifdef GC_UNDERSCORE_STDCALL # define GC_DllMain _GC_DllMain # endif -# if defined(WINAPI) /* windows.h included */ +# ifdef GC_WINDOWS_H_INCLUDED GC_API BOOL WINAPI GC_DllMain(HINSTANCE /* inst */, ULONG /* reason */, LPVOID /* reserved */); @@ -1681,7 +1688,7 @@ GC_API void GC_CALL GC_register_has_static_roots_callback( /* Currently the collector expects all threads to fall through and */ /* terminate normally, or call GC_endthreadex() or GC_ExitThread, */ /* so that the thread is properly unregistered. */ -# if defined(WINAPI) /* windows.h included */ +# ifdef GC_WINDOWS_H_INCLUDED GC_API HANDLE WINAPI GC_CreateThread( LPSECURITY_ATTRIBUTES /* lpThreadAttributes */, GC_WIN32_SIZE_T /* dwStackSize */,