Re: glib\guitls.h, atexit and the windows DDK
- From: Tor Lillqvist <tml iki fi>
- To: Rick Jones <rick jones2 hp com>
- Cc: gtk-list gnome org
- Subject: Re: glib\guitls.h, atexit and the windows DDK
- Date: Thu, 9 Mar 2006 02:36:08 +0200
> > The GLib (and GTK+, etc) headers
> > don't specify any calling convention, and things will go horribly
> > wrong if you compile code that calls GLib, GTK+ etc functions with the
> > wrong calling convention.
> I've no idea. My port isn't far enough along to know if anything
> actually _works_ or not.
You probably should build some helloworld type program that includes
some typical DDK headers without actually using any DDK functionality,
and includes <glib.h>, and just calls g_print("hello, dude\n") and see
what happens...
If using the DDK compiler means that something else than __cdecl is
the default calling convention, you need to surround the inclusion of
GLib, GTK+ etc headers with some suitable #pragma that turns the
default back to __cdecl.
But, after some browsing of MSDN I think there is no such #pragma,
unfortunately. In that case I guess you must separate those parts of
your code that use DDK functionality into separate source files from
those that use GLib, and compile the GLib-using ones with different
compiler switches so that __cdecl is the default calling
convention. (For those of your functions that forme the glue between
these two sets of differently compiled source files you obviously will
have to specify an explicit calling convention both in your headers
and implementations.)
The command-line switch to set __cdecl, __stdcall and __fastcall as
the default calling conventions are /Gd, /Gz and /Gr, respectively. If
nothing else is specified, __cdecl is the default, and this is what
all of GLib, GTK+ etc uses.
Note that getting the calling convention wrong is likely to mean the
program won't even link, as the compiler decorates the identifiers
generated for functions in the object files differently depending on
calling convention. So actually, if using the DDK headers and/or DDK
compiler means that it would attempt to call GLib functions using the
wrong calling convention, the helloworld test proggie mentioned above
shouldn't even link.
--tml
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]