www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/09/26/16:35:16

To: elio AT pvax DOT Ico DOT Olivetti DOT Com
Cc: sac AT cygnus DOT com (Steve Chamberlain), djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Using GCC for Windows apps/DLL's
Date: Mon, 26 Sep 94 09:04:31 -0700
From: sac AT cygnus DOT com

>> To cope with mixing PASCAL and non PASCAL calling conventions in the
>> same file, I added an 'attribute' keyword in my gcc and looked for
>> that when generating the calls - so you can do something like:
>> 
>> #define PASCAL __attribute__ ((pascal))
>> 
>> and then declare functions like this:
>> 
>> int foo (int a, int b) PASCAL ;
>> 
>> (I didn't change the parser so you could put the attribute in the same
>> place as Microsoft expects the PASCAL keyword).
>> 
>> You can change the order in which arguments are pushed by defining or
>> undefining the name ARGS_GROW_DOWNWARD.
>> 
>> This is where it started to get tricky.  My initial goal was to get
>> hello world appearing in a win32s screen, some of the library routines
>> I needed to call had PASCAL calling conventions, others did not.
>> That's simple - the 'attribute' springs to the rescue.  But others
>> seemed to need their args passed left to right, and some right to
>> left!  That can't be fixed in GCC without a non-trivial hack.

 
> I'm not sure to understand. If the PASCAL keyword takes care of changing
> the parameter passing convention, why do you need to use other tricks
> to get the right order?


The PASCAL keyword (using the attribute) can change the calling
convention so that the callee adjusts the stack before returning, and
it can do this on a per-function basis.

Unfortunately, Windows sometimes wants args passed right to left and
sometimes left to right.  Arg direction is specified when you compile
GCC, so you can't generate code which calls some functions left to
right and others right to left.

Steve





- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019