1
1
Debugging and troubleshooting
2
- ##########
2
+ #############################
3
3
4
4
This section is dedicated to the description of problems that
5
5
might appear while creating the python bindings with binder and the ways to avoid them.
@@ -13,15 +13,15 @@ Inconsistencies
13
13
14
14
Binder moves down the ``all_includes_file `` file sequentially, sometimes ending up with errors.
15
15
This is almost always caused by the ``all_includes_file `` being
16
- different between runs. The order shouldn't be important, but nail it down to at least be
16
+ different between runs. The order should not be important, but nail it down to at least be
17
17
consistent, and then move on to the next step.
18
18
19
19
--------------
20
20
Build failures
21
21
--------------
22
22
23
23
Even when the bindings were generated successfully, there might be compilation errors when building the modules from the generated sources.
24
- Quite often the errors are caused by the implementation of the С++ standard library, when the headers of the standard library
24
+ Quite often the errors are caused by the implementation of the C++ standard library, when the headers of the standard library
25
25
include each other, or include implementation-specific headers.
26
26
Many cases like that are already handled in the functions from the ``source/types.cpp `` file,
27
27
using the knowledge of the existing STL implementations.
@@ -38,7 +38,7 @@ For instance, the compilation could fail with the following error messages:
38
38
39
39
FAILED: CMakeFiles/statvec.dir/std/complex.o
40
40
In file included from std/complex.cpp:1:0:
41
- /usr/include/c++/7/bits/stl_construct.h: In function ‘ void std::_Destroy(_ForwardIterator, _ForwardIterator)’ :
41
+ /usr/include/c++/7/bits/stl_construct.h: In function ' void std::_Destroy(_ForwardIterator, _ForwardIterator)' :
42
42
**long and cryptic error message**
43
43
44
44
The ways to handle this error:
@@ -47,62 +47,63 @@ The ways to handle this error:
47
47
more information on the binded classes.
48
48
49
49
2. Since the includes from the ``bits `` directory should not appear in the generated code, one can grep for ``bits `` in the generated codes,
50
- i.e. ``grep -r "bits" cmake_bindings/* `` could yield:
51
-
52
- .. code-block :: console
53
-
54
- cmake_bindings/std/complex.cpp:#include <bits/stl_construct.h> // std::_Construct
55
- cmake_bindings/std/complex.cpp:#include <bits/stl_construct.h> // std::_Destroy
56
- cmake_bindings/std/complex.cpp:#include <bits/stl_construct.h> // std::_Destroy_aux
57
- cmake_bindings/std/complex.cpp:#include <bits/stl_construct.h> // std::_Destroy_aux<true>::__destroy
58
- cmake_bindings/std/complex.cpp:#include <bits/stl_construct.h> // std::_Destroy_n_aux
59
- cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_copy
60
- cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_copy<false>::__uninit_copy
61
- cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_copy<true>::__uninit_copy
62
- cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_copy_a
63
- cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_default_1
64
- cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_default_n
65
- cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_default_n_1
66
- cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_default_n_1<false>::__uninit_default_n
67
- cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_default_n_1<true>::__uninit_default_n
68
- cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_default_n_a
69
- cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_default_novalue_1
70
- cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_default_novalue_n_1
71
- cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_fill
72
- cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_fill_n
73
- cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_move_if_noexcept_a
74
- cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::uninitialized_copy
50
+ i.e. ``grep -r "bits" cmake_bindings/* `` could yield:
51
+
52
+
53
+ .. code-block :: console
54
+
55
+ cmake_bindings/std/complex.cpp:#include <bits/stl_construct.h> // std::_Construct
56
+ cmake_bindings/std/complex.cpp:#include <bits/stl_construct.h> // std::_Destroy
57
+ cmake_bindings/std/complex.cpp:#include <bits/stl_construct.h> // std::_Destroy_aux
58
+ cmake_bindings/std/complex.cpp:#include <bits/stl_construct.h> // std::_Destroy_aux<true>::__destroy
59
+ cmake_bindings/std/complex.cpp:#include <bits/stl_construct.h> // std::_Destroy_n_aux
60
+ cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_copy
61
+ cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_copy<false>::__uninit_copy
62
+ cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_copy<true>::__uninit_copy
63
+ cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_copy_a
64
+ cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_default_1
65
+ cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_default_n
66
+ cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_default_n_1
67
+ cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_default_n_1<false>::__uninit_default_n
68
+ cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_default_n_1<true>::__uninit_default_n
69
+ cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_default_n_a
70
+ cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_default_novalue_1
71
+ cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_default_novalue_n_1
72
+ cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_fill
73
+ cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_fill_n
74
+ cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::__uninitialized_move_if_noexcept_a
75
+ cmake_bindings/std/complex.cpp:#include <bits/stl_uninitialized.h> // std::uninitialized_copy
75
76
76
- The important information in the output is the ``std:: `` types/functions without the leading underscores.
77
- Those are STL-implementation independent types/functions that should be defined elsewhere, not in the headers from the ``bits `` directory.
78
- In this particular example, the function of interest is ``std::uninitialized_copy ``.
77
+ The important information in the output is the ``std:: `` types/functions without the leading underscores.
78
+ Those are STL-implementation independent types/functions that should be defined elsewhere, not in the headers from the ``bits `` directory.
79
+ In this particular example, the function of interest is ``std::uninitialized_copy ``.
79
80
80
- A quick search in the C++ documentation at https://en.cppreference.com or other resources tells that this function is defined in the <memory> header.
81
- Therefore, this information should be hardcoded into the binder.
81
+ A quick search in the C++ documentation at https://en.cppreference.com or other resources tells that this function is defined in the <memory> header.
82
+ Therefore, this information should be hardcoded into the binder.
82
83
83
84
84
85
3. The internal binder function that handles the STL library mappings is located in ``source/types.cpp ``:``add_relevant_include_for_decl ``.
85
- Briefly, the function has a map with the STL headers and the types those contain. That should look similar to this:
86
+ Briefly, the function has a map with the STL headers and the types those contain. That should look similar to this:
86
87
87
- .. code-block :: python
88
+ .. code-block :: C++
88
89
89
- { " <algorithm>" , {" std::move_backward" , " std::iter_swap" , " std::min" } },
90
- { " <exception>" , {" std::nested_exception" } }
90
+ { "<algorithm>", {"std::move_backward", "std::iter_swap", "std::min"} },
91
+ { "<exception>", {"std::nested_exception"} }
91
92
92
93
93
- If there is a need to make a simple change, like in our case, the map for the ``<memory> `` can be added like this:
94
+ If there is a need to make a simple change, like in our case, the map for the ``<memory> `` can be added like this:
94
95
95
- .. code-block :: python
96
+ .. code-block :: C++
96
97
97
- { " <algorithm>" , {" std::move_backward" , " std::iter_swap" , " std::min" } },
98
- { " <exception>" , {" std::nested_exception" } },
99
- { " <memory>" , {" std::uninitialized_copy" } },
98
+ { "<algorithm>", {"std::move_backward", "std::iter_swap", "std::min"} },
99
+ { "<exception>", {"std::nested_exception"} },
100
+ { "<memory>", {"std::uninitialized_copy"} },
100
101
101
102
102
- In addition to that, to ensure a better portability, some of the implementation-specific headers are replaced in binder with the standard ones.
103
- The map that holds the replacements is located in the ``source/types.cpp `` file as well. It should look similar to this:
103
+ In addition to that, to ensure a better portability, some of the implementation-specific headers are replaced in binder with the standard ones.
104
+ The map that holds the replacements is located in the ``source/types.cpp `` file as well. It should look similar to this:
104
105
105
- .. code-block :: python
106
+ .. code-block :: C++
106
107
107
108
static vector< std::pair<string, string> > const include_map = {
108
109
make_pair("<bits/ios_base.h>", "<ios>"),
@@ -115,4 +116,4 @@ The map that holds the replacements is located in the ``source/types.cpp`` file
115
116
In some cases, many iterations of the described procedure will be needed till all the STL types/functions will be mapped to the correct includes.
116
117
117
118
If this fixes your problem please let us know, or make a pull request!
118
-
119
+
0 commit comments