From: Gerhard Sittig Date: Mon, 14 Feb 2022 19:35:05 +0000 (+0100) Subject: libsigrokdecode.h: declare Windows dllexport for SRD_API routines X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=24ba9e1bdfe107e394176eda3116b714463a8437;p=libsigrokdecode.git libsigrokdecode.h: declare Windows dllexport for SRD_API routines Add the __declspec(dllexport) decoration to SRD_API routines on Windows when building the library body (this is new). Stick with the default visibility on all other platforms (as previously implemented). This is similar to what Kyle Johnson submitted in PR 66, but phrased differently. Avoid the non-portable indentation before the hash in preprocessor instructions. Use positive logic for readability (put the Windows branch next to the check for the Windows platform). Reported-By: Kyle Johnson --- diff --git a/libsigrokdecode.h b/libsigrokdecode.h index cf6479c..ea17cb8 100644 --- a/libsigrokdecode.h +++ b/libsigrokdecode.h @@ -106,17 +106,21 @@ enum srd_loglevel { */ /* Marks public libsigrokdecode API symbols. */ -#ifndef _WIN32 -#define SRD_API __attribute__((visibility("default"))) +#if defined _WIN32 +# if defined DLL_EXPORT +# define SRD_API __declspec(dllexport) +# else +# define SRD_API extern +# endif #else -#define SRD_API +# define SRD_API __attribute__((visibility("default"))) #endif /* Marks private, non-public libsigrokdecode symbols (not part of the API). */ -#ifndef _WIN32 -#define SRD_PRIV __attribute__((visibility("hidden"))) +#if defined _WIN32 +# define SRD_PRIV /* EMPTY */ #else -#define SRD_PRIV +# define SRD_PRIV __attribute__((visibility("hidden"))) #endif /*