Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitddb75d9

Browse files
committed
added cpp files
1 parent5f891ec commitddb75d9

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

‎bindings.cpp‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include<pybind11/pybind11.h>
2+
3+
namespacepy= pybind11;
4+
5+
PYBIND11_PLUGIN(cmake_example)
6+
{
7+
py::modulem("cmake_example",R"pbdoc(
8+
Pybind11 example plugin
9+
-----------------------
10+
.. currentmodule:: cmake_example
11+
.. autosummary::
12+
:toctree: _generate
13+
add
14+
subtract
15+
)pbdoc");
16+
17+
m.def("add", &add,R"pbdoc(
18+
Add two numbers
19+
Some other explanation about the add function.
20+
)pbdoc");
21+
22+
m.def("subtract", &subtract,R"pbdoc(
23+
Subtract two numbers
24+
Some other explanation about the subtract function.
25+
)pbdoc");
26+
27+
#ifdef VERSION_INFO
28+
m.attr("__version__") =py::str(VERSION_INFO);
29+
#else
30+
m.attr("__version__") =py::str("dev");
31+
#endif
32+
33+
return m.ptr();
34+
}

‎python_cpp_example/main.cpp‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include"main.hpp"
2+
3+
intadd(int i,int j)
4+
{
5+
return i + j;
6+
}
7+
8+
intsubtract(int i,int j)
9+
{
10+
return i - j;
11+
}

‎python_cpp_example/main.hpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
intadd(int i,int j);
2+
3+
intsubtract(int i,int j);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp