> Can anyone point me to a description of the Stdcall
> convention so I can understand better how it differs
> from C convention? ( I have some code that doesn't
> seem to care which convention is used - but the
> code below falls over with convention C)
> Is there a good reason for windows libraries to not use
> C convention?
> Or is it just an accident of Microsoft history?
It is an accident of Microsoft history. Stdcall is the modern version
of the _pascal calling convention which forces the C compiler to emit calls
which conform to the old Microsoft Pascal calling convention.
Under this convention, the called program cuts back the stack not the
caller. Hence it is important to know the exact size of the passed
parameter set and leads to mangling of the called routine names to indicate
the expected size.
Microsoft uses this convention for Windows because the original
implementation of Windows was written in Pascal and they were competing
(copying?) Apple's windowing interface which was also written in
Pascal. Inertia explains why Microsoft has not dropped this convention.
For the Purists: there is a slight speed and space advantage (at least for
very old 286 and 386 class machines) in using the _pascal convention over
the C convention.
David J.A. Koogler
Boolean Solutions, Ltd.