Using weak symbols rather than __attribute__((constructor)) preserves the linking order as on other platforms. --- src/Vendor.c.orig 2024-03-10 21:39:48 +++ src/Vendor.c 2024-05-22 23:44:47 @@ -111,20 +111,12 @@ * ***************************************************************************/ -#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__) +#if defined(__CYGWIN__) || defined(__MINGW32__) /* to fix the EditRes problem because of wrong linker semantics */ extern WidgetClass vendorShellWidgetClass; /* from Xt/Vendor.c */ extern VendorShellClassRec _XawVendorShellClassRec; extern void _XawFixupVendorShell(); -#if defined(__APPLE__) -__attribute__((constructor)) -static void __VendorShellHack(void) -{ - vendorShellWidgetClass = (WidgetClass)(&_XawVendorShellClassRec); - _XawFixupVendorShell(); -} -#else int __stdcall DllMain(unsigned long mod_handle, unsigned long flag, void *routine) { @@ -139,7 +131,6 @@ } return 1; } -#endif #define vendorShellClassRec _XawVendorShellClassRec @@ -155,6 +146,9 @@ }; #define SuperClass (&wmShellClassRec) +#if defined(__APPLE__) +__attribute__((weak)) +#endif externaldef(vendorshellclassrec) VendorShellClassRec vendorShellClassRec = { { /* superclass */ (WidgetClass)SuperClass, @@ -204,10 +198,11 @@ } }; -#if !defined(__APPLE__) +#if defined(__APPLE__) +__attribute__((weak)) +#endif externaldef(vendorshellwidgetclass) WidgetClass vendorShellWidgetClass = (WidgetClass) (&vendorShellClassRec); -#endif /*************************************************************************** * @@ -348,7 +343,7 @@ } } -#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__) +#if defined(__CYGWIN__) || defined(__MINGW32__) /* shared libraries on these platforms have the wrong semantics */ /* symbols do not get resolved external to the shared library */ void _XawFixupVendorShell()