Using weak symbols rather than __attribute__((constructor)) preserves the linking order as on other platforms. --- a/src/Vendor.c.orig 2023-05-13 04:08:46 +++ b/src/Vendor.c 2024-05-23 01:25:07 @@ -112,21 +112,12 @@ void XawVendorStructureNotifyHandler(Widget, XtPointer, XEvent*, Boolean*); -#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; void _XawFixupVendorShell(void); -#if defined(__APPLE__) -__attribute__((constructor)) -static void __VendorShellHack(void) -{ - vendorShellWidgetClass = (WidgetClass)(&_XawVendorShellClassRec); - _XawFixupVendorShell(); -} -#endif - #if defined(__CYGWIN__) || defined(__MINGW32__) int __stdcall DllMain(unsigned long, unsigned long, void *); @@ -162,6 +153,9 @@ #endif #define SuperClass (&wmShellClassRec) +#if defined(__APPLE__) +__attribute__((weak)) +#endif externaldef(vendorshellclassrec) VendorShellClassRec vendorShellClassRec = { { /* superclass */ (WidgetClass)SuperClass, @@ -223,10 +217,11 @@ } }; -#if !defined(__APPLE__) +#if defined(__APPLE__) +__attribute__((weak)) +#endif externaldef(vendorshellwidgetclass) WidgetClass vendorShellWidgetClass = (WidgetClass) (&vendorShellClassRec); -#endif #ifdef XAW_INTERNATIONALIZATION /*************************************************************************** @@ -470,7 +465,7 @@ } #endif -#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