// baby context cracking #if defined(_WIN32) # define OS_WINDOWS 1 #elif defined(__gnu_linux__) # define OS_LINUX 1 #else # error this configuration of compiler & OS is not supported #endif #if !defined(OS_WINDOWS) # define OS_WINDOWS 0 #endif #if !defined(OS_LINUX) # define OS_LINUX 0 #endif // linkage keyword abstraction #if OS_WINDOWS # define EXPORT_SYMBOL __declspec(dllexport) #elif OS_LINUX # define EXPORT_SYMBOL __attribute__ ((visibility ("default"))) #else # error keyword abstractions missing for this OS #endif // before-main abstraction #if OS_WINDOWS # pragma section(".CRT$XCU", read) # define BEFORE_MAIN(n) static void n(void); \ __declspec(allocate(".CRT$XCU")) \ __declspec(dllexport) \ void (*n##__)(void) = n; \ static void n(void) #elif OS_LINUX # define BEFORE_MAIN(n) \ __attribute__((constructor)) static void n(void) #else # error BEFORE_MAIN missing for this OS #endif // base symbols shared #if defined(BASE_IMPLEMENTOR) void base_func(void); #endif // dynamic function linkage protocol typedef struct BASE_Funcs{ #define X(N,R,P) R (*N) P; #include "base.xlist.h" #undef X } BASE_Funcs; typedef BASE_Funcs* BASE_ExportFuncs(void); #if defined(BASE_IMPLEMENTOR) EXPORT_SYMBOL BASE_Funcs* base_export_functions(void); #endif #if !defined(BASE_IMPLEMENTOR) #define X(N,R,P) R (*N) P = 0; #include "base.xlist.h" #undef X #endif