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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
a0162a12
Commit
a0162a12
authored
Jun 20, 2018
by
scoder
Committed by
GitHub
Jun 20, 2018
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
Show 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
)
docs/src/userguide/external_C_code.rst
View file @
a0162a12
...
@@ -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 ::
...
...
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