This repository was archived by the owner on Jan 26, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232#include <winsock2.h>
3333#endif
3434
35- #define CONSTRUCTOR_ATTRIBUTE __attribute__((constructor))
36- #define DESTRUCTOR_ATTRIBUTE __attribute__((destructor))
35+ #ifdef _MSC_VER
36+ #define CONSTRUCTOR_ATTRIBUTE (_func ) static void _func(void); \
37+ static int _func ## _wrapper(void) { _func(); return 0; } \
38+ __pragma(section(".CRT$XCU",read)) \
39+ __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _wrapper;
40+ #define DESTRUCTOR_ATTRIBUTE (_func ) static void _func(void); \
41+ static int _func ## _constructor(void) { atexit (_func); return 0; } \
42+ __pragma(section(".CRT$XCU",read)) \
43+ __declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
44+ #else
45+ #define CONSTRUCTOR_ATTRIBUTE (_func ) void _func(void) __attribute__((constructor))
46+ #define DESTRUCTOR_ATTRIBUTE (_func ) void _func(void) __attribute__((destructor))
47+ #endif
3748
3849/* Declare static mutex */
3950static SSH_MUTEX ssh_init_mutex = SSH_MUTEX_STATIC_INIT ;
@@ -44,8 +55,8 @@ static int _ssh_initialized = 0;
4455/* Cache the returned value */
4556static int _ssh_init_ret = 0 ;
4657
47- void libssh_constructor ( void ) CONSTRUCTOR_ATTRIBUTE ;
48- void libssh_destructor ( void ) DESTRUCTOR_ATTRIBUTE ;
58+ CONSTRUCTOR_ATTRIBUTE ( libssh_constructor ) ;
59+ DESTRUCTOR_ATTRIBUTE ( libssh_destructor ) ;
4960
5061static int _ssh_init (unsigned constructor ) {
5162
You can’t perform that action at this time.
0 commit comments