Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
9bb97c1b
Commit
9bb97c1b
authored
Jun 03, 2016
by
Wenzel Jakob
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs: added a general note about macro usage
parent
99279f71
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
8 deletions
+20
-8
docs/advanced.rst
+20
-8
No files found.
docs/advanced.rst
View file @
9bb97c1b
...
@@ -318,14 +318,7 @@ a virtual method call.
...
@@ -318,14 +318,7 @@ a virtual method call.
>>> call_go(c)
>>> call_go(c)
u'meow! meow! meow! '
u'meow! meow! meow! '
.. warning::
Please take a look at the :ref:`macro_notes` before using this feature.
The :func:`PYBIND11_OVERLOAD_*` calls are all just macros, which means that
they can get confused by commas in a template argument such as
``PYBIND11_OVERLOAD(MyReturnValue<T1, T2>, myFunc)``. In this case, the
preprocessor assumes that the comma indicates the beginnning of the next
parameter. Use a ``typedef`` to bind the template to another name and use
it in the macro to avoid this problem.
.. seealso::
.. seealso::
...
@@ -334,6 +327,21 @@ a virtual method call.
...
@@ -334,6 +327,21 @@ a virtual method call.
detail.
detail.
.. _macro_notes:
General notes regarding convenience macros
==========================================
pybind11 provides a few convenience macros such as
:func:`PYBIND11_MAKE_OPAQUE` and :func:`PYBIND11_DECLARE_HOLDER_TYPE`, and
``PYBIND11_OVERLOAD_*``. Since these are "just" macros that are evaluated
in the preprocessor (which has no concept of types), they *will* get confused
by commas in a template argument such as ``PYBIND11_OVERLOAD(MyReturnValue<T1,
T2>, myFunc)``. In this case, the preprocessor assumes that the comma indicates
the beginnning of the next parameter. Use a ``typedef`` to bind the template to
another name and use it in the macro to avoid this problem.
Global Interpreter Lock (GIL)
Global Interpreter Lock (GIL)
=============================
=============================
...
@@ -721,6 +729,9 @@ There are two ways to resolve this issue:
...
@@ -721,6 +729,9 @@ There are two ways to resolve this issue:
class Child : public std::enable_shared_from_this<Child> { };
class Child : public std::enable_shared_from_this<Child> { };
Please take a look at the :ref:`macro_notes` before using this feature.
.. seealso::
.. seealso::
The file :file:`example/example8.cpp` contains a complete example that
The file :file:`example/example8.cpp` contains a complete example that
...
@@ -903,6 +914,7 @@ with a name in Python, and to define a set of available operations:
...
@@ -903,6 +914,7 @@ with a name in Python, and to define a set of available operations:
}, py::keep_alive<0, 1>()) /* Keep vector alive while iterator is used */
}, py::keep_alive<0, 1>()) /* Keep vector alive while iterator is used */
// ....
// ....
Please take a look at the :ref:`macro_notes` before using this feature.
.. seealso::
.. seealso::
...
...
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