diff --git a/documentation/current/solutions/other-languages/eiffel-external-mechanism/obsolete-external-interfaces/c-externals.wiki b/documentation/current/solutions/other-languages/eiffel-external-mechanism/obsolete-external-interfaces/c-externals.wiki index acca5656..4f54a696 100644 --- a/documentation/current/solutions/other-languages/eiffel-external-mechanism/obsolete-external-interfaces/c-externals.wiki +++ b/documentation/current/solutions/other-languages/eiffel-external-mechanism/obsolete-external-interfaces/c-externals.wiki @@ -30,39 +30,39 @@ extern size_t one_param_return(FILE *f); Here is the corresponding Eiffel code: - c_no_param - -- Encapsulation of a C routine with no parameter. - external - "C | %"my_header.h%"" - alias - "no_param" - end + c_no_param + -- Encapsulation of a C routine with no parameter. + external + "C | %"my_header.h%"" + alias + "no_param" + end - c_one_param (i: INTEGER) - -- Encapsulation of a C routine with one parameter. - external - "C (int) | %"my_header.h%"" - alias - "one_param" - end + c_one_param (i: INTEGER) + -- Encapsulation of a C routine with one parameter. + external + "C (int) | %"my_header.h%"" + alias + "one_param" + end - c_no_param_return: INTEGER - -- Encapsulation of a C routine with no parameter - -- returning an INTEGER - external - "C (): EIF_INTEGER| %"my_header.h%"" - alias - "no_param_return" - end + c_no_param_return: INTEGER + -- Encapsulation of a C routine with no parameter + -- returning an INTEGER + external + "C (): EIF_INTEGER| %"my_header.h%"" + alias + "no_param_return" + end - c_one_param_return (p: POINTER): INTEGER - -- Encapsulation of a C routine with one parameter - -- returning an INTEGER - external - "C (FILE *): EIF_INTEGER| %"my_header.h%"" - alias - "one_param_return" - end + c_one_param_return (p: POINTER): INTEGER + -- Encapsulation of a C routine with one parameter + -- returning an INTEGER + external + "C (FILE *): EIF_INTEGER| %"my_header.h%"" + alias + "one_param_return" + end @@ -82,29 +82,29 @@ Then, the corresponding Eiffel code will look like: - menu_id: INTEGER - -- `ID_MENU' C encapsulation. - external - "C [macro %"my_header.h%"] : EIF_INTEGER" - alias - "ID_MENU" - end + menu_id: INTEGER + -- `ID_MENU' C encapsulation. + external + "C [macro %"my_header.h%"] : EIF_INTEGER" + alias + "ID_MENU" + end - menu_id_character: CHARACTER - -- `ID_MENU_CHARACTER' C encapsulation. - external - "C [macro %"my_header.h%"] : EIF_CHARACTER" - alias - "ID_MENU_CHARACTER" - end + menu_id_character: CHARACTER + -- `ID_MENU_CHARACTER' C encapsulation. + external + "C [macro %"my_header.h%"] : EIF_CHARACTER" + alias + "ID_MENU_CHARACTER" + end - i_th (p: POINTER; i: INTEGER): INTEGER - -- Access the `i'-th element of `p', array of C EIF_INTEGER. - external - "C [macro %"my_header.h%"] (EIF_INTEGER *, EIF_INTEGER): EIF_INTEGER" - alias - "i_th" - end + i_th (p: POINTER; i: INTEGER): INTEGER + -- Access the `i'-th element of `p', array of C EIF_INTEGER. + external + "C [macro %"my_header.h%"] (EIF_INTEGER *, EIF_INTEGER): EIF_INTEGER" + alias + "i_th" + end @@ -125,37 +125,37 @@ typdef struct point { Then, the corresponding Eiffel code will look like: - x (p: POINTER): INTEGER - -- Access field x of struct pointed by `p'. - external - "C [struct %"my_header.h%"] (Point): EIF_INTEGER" - alias - "x" - end + x (p: POINTER): INTEGER + -- Access field x of struct pointed by `p'. + external + "C [struct %"my_header.h%"] (Point): EIF_INTEGER" + alias + "x" + end - y (p: POINTER): INTEGER - -- Access field y of struct pointed by `p'. - external - "C [struct %"my_header.h%"] (Point): EIF_INTEGER" - alias - "y" - end + y (p: POINTER): INTEGER + -- Access field y of struct pointed by `p'. + external + "C [struct %"my_header.h%"] (Point): EIF_INTEGER" + alias + "y" + end - set_x (p: POINTER; v: INTEGER) - -- Set field x of struct pointed by `p'. - external - "C [struct %"my_header.h%"] (Point, int)" - alias - "x" - end + set_x (p: POINTER; v: INTEGER) + -- Set field x of struct pointed by `p'. + external + "C [struct %"my_header.h%"] (Point, int)" + alias + "x" + end - set_y (p: POINTER: v: INTEGER) - -- Set field y of struct pointed by `p' with `v'. - external - "C [struct %"my_header.h%"] (Point, int)" - alias - "y" - end + set_y (p: POINTER: v: INTEGER) + -- Set field y of struct pointed by `p' with `v'. + external + "C [struct %"my_header.h%"] (Point, int)" + alias + "y" + end @@ -171,17 +171,17 @@ Therefore if you want to call an external routine defined in a DLL supposed to b - my_cdecl_routine (a: INTEGER): POINTER - -- Encapsulation of a dll function with the `_cdecl' call mechanism. - external - "C [dll32 %"my_dll.dll%"] (int): EIF_POINTER" - end + my_cdecl_routine (a: INTEGER): POINTER + -- Encapsulation of a dll function with the `_cdecl' call mechanism. + external + "C [dll32 %"my_dll.dll%"] (int): EIF_POINTER" + end - my_stdcall_routine (a: INTEGER): POINTER - -- Encapsulation of a dll function with the `_stdcall' call mechanism. - external - "C [dllwin32 %"my_dll.dll%"] (int): EIF_POINTER" - end + my_stdcall_routine (a: INTEGER): POINTER + -- Encapsulation of a dll function with the `_stdcall' call mechanism. + external + "C [dllwin32 %"my_dll.dll%"] (int): EIF_POINTER" + end {{warning|Using '''dll32''' in cases calling for '''dllwin32''' and vice versa will cause your system to crash, because the C call stack will be corrupted. For more information please read your C compiler documentation. }} @@ -207,13 +207,13 @@ In WEL, the encapsulation is written as: - cwin_send_message (hwnd: POINTER; msg, wparam, param: INTEGER) - -- SDK SendMessage (without the result) - external - "C [macro %"wel.h%"] (HWND, UINT, WPARAM, LPARAM)" - alias - "SendMessage" - end + cwin_send_message (hwnd: POINTER; msg, wparam, param: INTEGER) + -- SDK SendMessage (without the result) + external + "C [macro %"wel.h%"] (HWND, UINT, WPARAM, LPARAM)" + alias + "SendMessage" + end {{seealso|