|
From: Mario E. <ma...@em...> - 2022-09-19 15:07:30
|
I've just stared using SWIG and like it a lot. However I've also found
some bottlenecks. One such bottleneck is the use of preprocessor macros
in our code. For example, we use boost::pp to generate enums that have
safe conversion functions to and from int and std::string. However SWIG
does not resolve the macros (by default), and instead throws on the
unusable code.
I have seen there is the -includeall switch that may help to include the
boost::pp headers and resolve the macro. But from the documentation I
understand that when using this switch, SWIG will generate bindings to
*all* included headers, and that is not what we want (there are many
STL and similar headers in use).
So I did not find a straightforward solution in the SWIG docs, and
decided to try something else: Calling the clang preprocessor on the
source files, and removing the "included" code afterwards. That worked
surprisingly well, and generated a fully resolved source file, which
SWIG happily accepts.
This motivates my question: Does SWIG have such a functionality built-
in? A way to include all headers (in order to resolve macros etc), but
not generate code for the included headers?
I can see how this would be quite helpful in many cases. Is this
something that exists or was considered, and what do others think
about it?
All the best,
Mario Emmenlauer
|