2

I am new to cython. I have a project file project_file.pyx which I would like to manually create a .cpp file with.

I have tried cython project_file.pyx but this produces project_file .c. However I would like to produce the file project_file.cpp.

How can I do this? I'm running a Linux environment.

halfer
  • 19,824
  • 17
  • 99
  • 186
Stacey
  • 4,825
  • 17
  • 58
  • 99
  • This answer lists all the options: https://stackoverflow.com/a/63838304/5769463 – ead Mar 09 '21 at 14:12

2 Answers2

1

You should put this line at the top of your .pyx file:

# distutils: language = c++

This should compile it in to a .cpp file.

user1321988
  • 513
  • 2
  • 6
0

Use the --cplus flag.

cython --cplus project_file.pyx

brian
  • 157
  • 2
  • 10