TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Forum View

Use Monospaced Font
Show HTML Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
David Koogler <[log in to unmask]>
Reply To:
David Koogler <[log in to unmask]>
Tue, 1 Dec 1998 11:14:36 -0500
text/plain (30 lines)
> 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.