Re: C library interface



Stephen Pelc <stephenXXX@xxxxxxxxxxxx> wrote:

Bernd's excellent survey is really about implementation, but at the
moment I'm more worried about notation. There are currently three
models in use:

4 1 Function: PostMessage

Outside: PostMessage { hwnd mesg wparam lparam -- bool }

Extern: BOOL PostMessage(
HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
);

The Function: notation assumes that everything is a cell. It does
and always will fail on some systems, especially for floats and for
items less than a cell. Many variants assume that a single cell is
always returned.

The Outside: notation is not bad but throws away some information that
is useful for self-documenting code. Overall, the parsing requirements
are much the same as for the Extern: notation.

The Extern: notation throws least information away. It's basically
the same as the libcc approach (parse the C header) with a totally
different implementation approach.

But AFAICS libcc doesn't parse anything; the C compiler does.

To provide library portability we need to be able to define an alias
because the library code may use a different stack order.
LocalExtern: p_PostMessage BOOL PostMessage(
HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
);

To this we need to be able to specify the stack order, e.g. L>R or
R>L, the call type, e.g. "C" or "PASCAL" or WINAPI or FORTRAN

All of this is horribly nonportable. The stack order is declared in
the header file for the function, at least if you use the libcc
technique. There seems to be no reason to expose all this
implementation stuff for a standard reference implementation.

Andrew.
.



Relevant Pages

  • Re: how to tell if hwnd is valid
    ... HWND hWnd, ... WPARAM wParam, ... LPARAM lParam ... If the function succeeds, ...
    (microsoft.public.vc.mfc)
  • Re: SIP options dialog
    ... I copy and paste your sample code: ... > BOOL IM_OptionsDlg(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) ...
    (microsoft.public.pocketpc.developer)
  • rs232- [C]
    ... LRESULT CALLBACK WndProc_CW1 (HWND hwnd, UINT message, ... WPARAM wParam, LPARAM lParam) ... // A serial message occurred ...
    (microsoft.public.vc.language)
  • Re: Combobox width
    ... >> HWND hWnd, ... >> WPARAM wParam, ... >> LPARAM lParam ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: MessageBox mit eingener Instanz
    ... int WINAPI WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) ...
    (microsoft.public.de.vc)