From c34ee888e802fb76f5cf2a9cfba3685429d1d4be Mon Sep 17 00:00:00 2001 From: halw Date: Sat, 8 Dec 2012 19:03:06 +0000 Subject: [PATCH] Author:halw Date:2012-12-08T19:03:06.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@1205 abb3cda0-5349-4a8f-a601-0c33ac3a8c38 --- .../interfacing-c-and-c.wiki | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/documentation/current/solutions/other-languages/eiffel-external-mechanism/interfacing-c-and-c.wiki b/documentation/current/solutions/other-languages/eiffel-external-mechanism/interfacing-c-and-c.wiki index 4b5a1c3e..726703d5 100644 --- a/documentation/current/solutions/other-languages/eiffel-external-mechanism/interfacing-c-and-c.wiki +++ b/documentation/current/solutions/other-languages/eiffel-external-mechanism/interfacing-c-and-c.wiki @@ -20,5 +20,23 @@ Here is an example of an external targeting an existing C function. In this case The Eiffel external function floor now gives Eiffel code access to the C library function of the same name. +Here external is an Eiffel keyword that introduces the external specification that appears in the quoted string that follows. Within the quoted string we find first the registered language designator, in this case "C", followed by the function's signature, followed by the location in which the C function can be found. The terms "signature" and "use" within the quoted string are technically not Eiffel language keywords, but are keywords used in the specification of externals. There is one other similar keyword "inline" which can be used, but we will address it later. + +The "signature" consists of the types of the arguments to C function as well as the function's return type. The argument types are separated by commas in a list enclosed in parentheses. A colon precedes the function type. In cases in which the target function takes no arguments, it is not necessary to include a set of empty parentheses in the signature. However, for compatibility purposes, the empty parentheses are allowed. + +The "use" part denotes provides a file name or list of file names. File names can be either "user" file names or "system" file names. In the case of our example, a system file name "" is used. System files are those that should be found by the system with no additional information. System file names are enclosed in angle brackets. User file names are included in a quoted string. + +In the example above, the Eiffel function has the same name as the C function it targets. But that may not always be the case. It's possible that the C function name might conflict with a name already established in your class, or might conflict with Eiffel naming conventions. Suppose you wanted to call the Eiffel routine my_floor instead of floor. You could use the alias part of the external specification to state that the actual C function name differs from the Eiffel name, as shown below. + + + my_floor (v: DOUBLE): DOUBLE + -- Floor of `v' + external + "C signature (double): double use " + alias + "floor" + end + +