Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
a0162a12
Commit
a0162a12
authored
6 years ago
by
scoder
Committed by
GitHub
6 years ago
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2367 from gabrieldemarmiesse/test_external_c_code
Added tests to "Interfacing with external C code" part 1
parents
1da328ad
63b3b849
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
docs/examples/userguide/external_C_code/c_code_docstring.pyx
docs/examples/userguide/external_C_code/c_code_docstring.pyx
+9
-0
docs/src/userguide/external_C_code.rst
docs/src/userguide/external_C_code.rst
+2
-10
No files found.
docs/examples/userguide/external_C_code/c_code_docstring.pyx
0 → 100644
View file @
a0162a12
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
)
This diff is collapsed.
Click to expand it.
docs/src/userguide/external_C_code.rst
View file @
a0162a12
...
...
@@ -332,17 +332,9 @@ Including verbatim 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 *:
"""
/* 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)
.. literalinclude:: ../../examples/userguide/external_C_code/c_code_docstring.pyx
The above is essentially equivalent to having the C code in a file
``header.h`` and writing ::
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment