Commit a0162a12 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2367 from gabrieldemarmiesse/test_external_c_code

Added tests to "Interfacing with external C code" part 1
parents 1da328ad 63b3b849
cdef extern from *:
"""
/* This is C code which will be put
* in the .c file output by Cython */
static long square(long x) {return x * x;}
#define assign(x, y) ((x) = (y))
"""
long square(long x)
void assign(long& x, long y)
...@@ -332,17 +332,9 @@ Including verbatim C code ...@@ -332,17 +332,9 @@ Including verbatim C code
------------------------- -------------------------
For advanced use cases, Cython allows you to directly write C code For advanced use cases, Cython allows you to directly write C code
as "docstring" of a ``cdef extern from`` block:: as "docstring" of a ``cdef extern from`` block:
cdef extern from *: .. literalinclude:: ../../examples/userguide/external_C_code/c_code_docstring.pyx
"""
/* This is C code which will be put
* in the .c file output by Cython */
static long square(long x) {return x * x;}
#define assign(x, y) ((x) = (y))
"""
long square(long x)
void assign(long& x, long y)
The above is essentially equivalent to having the C code in a file The above is essentially equivalent to having the C code in a file
``header.h`` and writing :: ``header.h`` and writing ::
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment