cmake_example/src/main.cpp
2016-06-10 22:04:04 +02:00

46 lines
868 B
C++

#include <pybind11/pybind11.h>
int add(int i, int j) {
return i + j;
}
int subtract(int i, int j) {
return i - j;
}
namespace py = pybind11;
PYBIND11_PLUGIN(cmake_example) {
py::module m("cmake_example", R"pbdoc(
Pybind11 example plugin
-----------------------
.. currentmodule:: cmake_example
.. autosummary::
:toctree: _generate
add
subtract
)pbdoc");
m.def("add", &add, R"pbdoc(
Add two numbers
Some other explanation about the add function.
)pbdoc");
m.def("subtract", &subtract, R"pbdoc(
Subtract two numbers
Some other explanation about the subtract function.
)pbdoc");
#ifdef VERSION_INFO
m.attr("__version__") = py::str(VERSION_INFO);
#else
m.attr("__version__") = py::str("dev");
#endif
return m.ptr();
}