Hi,
Related to the definition of __DLL_IMPORT below, the cygwin port of
glib/gmodule just does the following:
#define G_MODULE_IMPORT extern
#ifdef G_PLATFORM_WIN32
# define G_MODULE_EXPORT __declspec(dllexport)
#else /* !G_PLATFORM_WIN32 */
# define G_MODULE_EXPORT
#endif /* !G_PLATFORM_WIN32 */
Also, it doesn't make any distinction whether you are building a DLL or not.
The following example has been tested and it works (I've done the
example without gmodule, as we wouldn't want to use that within
postgresql anyways):
dll.h:
extern void foo();
dll.c:
#include "dll.h"
__declspec(dllexport) void foo() {return;
}
main.c:
#include "dll.h"
int main(int argc, char **argv) {foo();return 0;
}
This is with recent GCC (3.3.3 on my system), but it probably also works with older GCC versions.
Don't know if this information is useful in simplying things...
Maarten
Reini Urban wrote:
> #ifdef BUILDING_DLL
> # ifndef __GNUC__
> # define __DLL_IMPORT __declspec(dllimport)
> # else
> # define __DLL_IMPORT __attribute__((dllimport)) extern
> # endif
> #else
> # define __DLL_IMPORT
> #endif