Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

updated/fixed rectangle example files (Rectangle.cpp and rectangle.pyx)

  • Loading branch information...
commit 37486422dd5fffae1e3ea72c58bfac4bba56144d 1 parent f54a030
Angus McMorland authored August 22, 2011

Showing 1 changed file with 11 additions and 9 deletions. Show diff stats Hide diff stats

  1. 20  docs/src/userguide/wrapping_CPlusPlus.rst
20  docs/src/userguide/wrapping_CPlusPlus.rst
Source Rendered
@@ -65,6 +65,8 @@ and the implementation in the file called :file:`Rectangle.cpp`:
65 65
 
66 66
     #include "Rectangle.h"
67 67
 
  68
+    using namespace shapes;
  69
+
68 70
     Rectangle::Rectangle(int X0, int Y0, int X1, int Y1)
69 71
     {
70 72
         x0 = X0;
@@ -109,15 +111,15 @@ In Cython :file:`setup.py` scripts, one normally instantiates an Extension
109 111
 object. To make Cython generate and compile a C++ source, you just need
110 112
 to add the keyword ``language="c++"`` to your Extension construction statement, as in::
111 113
 
112  
-    ext = Extension(
113  
-        "rectangle",                 # name of extension
114  
-        ["rectangle.pyx", "Rectangle.cpp"],     # filename of our Cython source
115  
-        language="c++",              # this causes Cython to create C++ source
116  
-        include_dirs=[...],          # usual stuff
117  
-        libraries=["stdc++", ...],             # ditto
118  
-        extra_link_args=[...],       # if needed
119  
-        cmdclass = {'build_ext': build_ext}
120  
-        )
  114
+   from distutils.core import setup
  115
+   from distutils.extension import Extension
  116
+   from Cython.Distutils import build_ext
  117
+
  118
+   setup(ext_modules=[Extension(
  119
+                      "rectangle",                 # name of extension
  120
+                      ["rectangle.pyx", "Rectangle.cpp"], #  our Cython source
  121
+                      language="c++")],  # causes Cython to create C++ source
  122
+         cmdclass={'build_ext': build_ext})
121 123
 
122 124
 Cython will generate and compile the :file:`rectangle.cpp` file (from the
123 125
 :file:`rectangle.pyx`), then it will compile :file:`Rectangle.cpp`

0 notes on commit 3748642

Please sign in to comment.
Something went wrong with that request. Please try again.