Author:halw

Date:2012-12-07T22:16:45.000000Z


git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@1204 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
halw
2012-12-07 22:16:45 +00:00
parent f7954528b1
commit c8ed03b84a

View File

@@ -4,5 +4,21 @@
{{UnderConstruction}} {{UnderConstruction}}
Interfacing with C and C++ are similar enough that both can be covered together. There are two basic mechanisms available. The first and simpler of the two uses an existing routine and is available only to C externals. Using this approach you simply specify the '''signature''' of an existing C function along with where the function can be found. The second mechanism allows you to write C or C++ code inline. The second option is always recognizable by the presence of the word "'''inline'''" in the external specification. Again, the '''inline''' option is the only one allowed for C++ externals.
==Using an existing C function==
Here is an example of an external targeting an existing C function. In this case it's the <code>floor</code> function from the C library.
<code>
floor (v: DOUBLE): DOUBLE
-- Floor of `v'
external
"C signature (double): double use <math.h>"
end
</code>
The Eiffel external function <code>floor</code> now gives Eiffel code access to the C library function of the same name.