From cac876ca2d67282a329c0058a5d0cbb82c0c0a8b Mon Sep 17 00:00:00 2001 From: Stephen Hutchinson Date: Wed, 14 Jan 2026 11:37:31 -0500 Subject: [PATCH 1/2] avisynth.h: force C-style linkage outside of Windows/x86 --- avs_core/include/avisynth.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/avs_core/include/avisynth.h b/avs_core/include/avisynth.h index 84fa4f8da..908918993 100644 --- a/avs_core/include/avisynth.h +++ b/avs_core/include/avisynth.h @@ -115,6 +115,12 @@ #define __cdecl #endif +// Use C-style linkage on Windows if targetting any CPU architecture +// other than legacy x86 +#if defined(AVS_WINDOWS) && !defined(AVS_WINDOWS_X86) +extern "C" { +#endif + // Important note on AVISYNTH_INTERFACE_VERSION V6->V8 change: // Note 1: Those few plugins which were using earlier IScriptEnvironment2 despite the big Warning will crash have to be rebuilt. // Note 2: How to support earlier avisynth interface with an up-to-date avisynth.h: @@ -2054,4 +2060,8 @@ AVSC_API(IScriptEnvironment2*, CreateScriptEnvironment2)(int version = AVISYNTH_ #pragma pack(pop) +#if defined(AVS_WINDOWS) && !defined(AVS_WINDOWS_X86) +} +#endif // extern "C" + #endif //__AVISYNTH_12_H__ From 535cca07166796ba4f67366878b9cb33e0c6c33c Mon Sep 17 00:00:00 2001 From: Stephen Hutchinson Date: Tue, 3 Feb 2026 04:32:49 -0500 Subject: [PATCH 2/2] avisynth.h: clean up scattered #includes --- avs_core/include/avisynth.h | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/avs_core/include/avisynth.h b/avs_core/include/avisynth.h index 908918993..38c94f9ca 100644 --- a/avs_core/include/avisynth.h +++ b/avs_core/include/avisynth.h @@ -100,6 +100,7 @@ #include "avs/config.h" #include "avs/capi.h" +#include "avs/cpuid.h" #include "avs/types.h" #ifdef AVS_POSIX @@ -115,12 +116,6 @@ #define __cdecl #endif -// Use C-style linkage on Windows if targetting any CPU architecture -// other than legacy x86 -#if defined(AVS_WINDOWS) && !defined(AVS_WINDOWS_X86) -extern "C" { -#endif - // Important note on AVISYNTH_INTERFACE_VERSION V6->V8 change: // Note 1: Those few plugins which were using earlier IScriptEnvironment2 despite the big Warning will crash have to be rebuilt. // Note 2: How to support earlier avisynth interface with an up-to-date avisynth.h: @@ -171,7 +166,17 @@ enum AvsVersion { #define _ASSERT(x) assert(x) #endif +#if defined(BUILDING_AVSCORE) || defined(AVS_STATIC_LIB) +# ifndef offsetof +# include +# endif +#endif +// Use C-style linkage on Windows if targetting any CPU architecture +// other than legacy x86 +#if defined(AVS_WINDOWS) && !defined(AVS_WINDOWS_X86) +extern "C" { +#endif // I had problems with Premiere wanting 1-byte alignment for its structures, // so I now set the Avisynth struct alignment explicitly here. @@ -516,10 +521,6 @@ extern __declspec(dllimport) const AVS_Linkage* const AVS_linkage; extern const AVS_Linkage* AVS_linkage; # endif -# ifndef offsetof -# include -# endif - # define AVS_BakedCode(arg) { arg ; } # define AVS_LinkCall(arg) !AVS_linkage || offsetof(AVS_Linkage, arg) >= (size_t)AVS_linkage->Size ? 0 : (this->*(AVS_linkage->arg)) # define AVS_LinkCall_Void(arg) !AVS_linkage || offsetof(AVS_Linkage, arg) >= (size_t)AVS_linkage->Size ? (void)0 : (this->*(AVS_linkage->arg)) @@ -1531,8 +1532,6 @@ class PFunction #undef AVS_BakedCode -#include "avs/cpuid.h" - // IScriptEnvironment GetEnvProperty enum AvsEnvProperty { AEP_PHYSICAL_CPUS = 1, @@ -2051,7 +2050,6 @@ AVSC_API(IScriptEnvironment*, CreateScriptEnvironment)(int version = AVISYNTH_IN #define VARNAME_Enable_PlanarToPackedRGB "OPT_Enable_PlanarToPackedRGB" // AVS+ convert Planar RGB to packed RGB (VfW) // C exports -#include "avs/capi.h" AVSC_API(IScriptEnvironment2*, CreateScriptEnvironment2)(int version = AVISYNTH_INTERFACE_VERSION); #ifndef BUILDING_AVSCORE