From: Magnus Jacobsson Date: Tue, 14 Sep 2021 14:27:04 +0000 (+0200) Subject: common: unify diverged storage-class attributes in globals.h X-Git-Tag: 2.49.2~32^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e01f4a96848807ed07a00cee5351ec8b4d4dde49;p=graphviz common: unify diverged storage-class attributes in globals.h The immediate reason for this commit is to fix a bug when using the autools build system with Cygwin, described below, but it is also a step towards https://gitlab.com/graphviz/graphviz/-/issues/2058#note_678679545. This file had one set of Windows-specific storage-class attribute declarations intended for use with the autotools build system and one set intended for use with Visual Studio, with slightly different control mechanisms. It's unclear what effect changes made to these control mechanisms over the years has had on the many operating systems that are not tested in CI. The current state is that they partly overlap and are very hard to understand. This commit cleans this up by applying such declarations only if the GVDLL or the WIN32_DLL symbol is set. An export declaration is used if either the GVC_EXPORT or the _BLD_GVC symbol is defined and an import declaration otherwise. Using both GVDLL and WIN32_DLL for the same purpose is a temporary measure and will be replaced by only one symbol in an upcoming commit series towards https://gitlab.com/graphviz/graphviz/-/issues/2058#note_678679545. Since https://gitlab.com/graphviz/graphviz/-/merge_requests/2182, setting GVDLL is the preferred single mechanism to enable those attributes, rather than using _WIN32 and __CYGWIN__ plus some other symbol to distinguish between static and dynamic-link/shared libraries. Likewise is the use of both GVC_EXPORT and _BLD_gvc for the same purpose a temporary measure, which will be replaced by only one symbol in an upcoming commit series towards https://gitlab.com/graphviz/graphviz/-/issues/2058#note_678679545. This fixes a segmentation fault when running 'dot -c' during 'make install' on Cygwin. Debugging with gdb showed that this happened on line 99 in dot.c: GvExitOnUsage = 1; --- diff --git a/lib/common/globals.h b/lib/common/globals.h index 30165dab6..1c11a2d7b 100644 --- a/lib/common/globals.h +++ b/lib/common/globals.h @@ -14,20 +14,13 @@ extern "C" { #endif -#ifndef __CYGWIN__ -#if defined(GVDLL) -#if !defined(_BLD_gvc) -#define DECLSPEC __declspec(dllimport) -#endif -#endif -#endif -/*visual studio*/ -#ifdef _WIN32 -#ifndef GVC_EXPORTS +#if defined(GVDLL) || defined(WIN32_DLL) +#if defined(GVC_EXPORTS) || defined(_BLD_gvc) +#define DECLSPEC __declspec(dllexport) +#else #define DECLSPEC __declspec(dllimport) #endif #endif -/*end visual studio*/ #ifndef DECLSPEC #define DECLSPEC /* nothing */