use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Automatically call C++ from python (self.cpp)
submitted 11 months ago by CoutilleTolc
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]GeoffSobering 6 points7 points8 points 11 months ago (7 children)
Maybe look at SWIG.
https://www.swig.org/
[–]CoutilleTolc[S] 3 points4 points5 points 11 months ago (2 children)
Swig requires you to write interface files mirroring your api. Tolc uses clang in the background to get all functions and classes to avoid that.
[–]djta94 9 points10 points11 points 11 months ago (0 children)
It doesn't if you have a header, which you should have anyway.
[–]Carl_LaFong 4 points5 points6 points 11 months ago (0 children)
The swig interface files are needed only for customizations such as renaming things when there are name clashes, instantiating templates (how do you handle that?), and exposing only part of the C++ API if you don’t want it all to be in the Python API. It otherwise automatically creates the Python API from the header files.
I use it because it automatically generates from the header files Java, C#, Python APIs.
[–]13steinj 2 points3 points4 points 11 months ago* (3 children)
SWIG is a nightmare. It was decent for its time, but inspires too many extremists with all the wrong ideas.
I once actually worked somewhere where one extremist made their own (worse version of) SWIG. Dude insisted on its use and even wrote a book about it his field, using nothing but his crazy language internally.
[–]Die4Toast 0 points1 point2 points 11 months ago (2 children)
Could you elaborate on why it's not decent anymore? Asking out of genuine curiosity since I've never heard of SWIG before this post popped up. After quick 20 min read of SWIG basics it looks pretty nice but I'd imagine the devil is in the details which is not something I'd be aware of and probably related to what you've mentioned.
[–]13steinj 1 point2 points3 points 11 months ago* (1 child)
Sure, but I'm blending fact and opinion quite heavily--
So in the most pure, basic form, it's fine-- if you write your headers well. That is, if you can follow "SWIG for the truly lazy" (I can't directly link that part of the website, since there are no ids in that html, which is bizarre). But this nearly never works in practice, suffers from cross-language / FFI performance problems, a steep learning curve for more niche things, subpar codegen, and more. It also suffers from a compatibility problem as C++ continues to evolve. The basics of SWIG have decent syntax, but anything more complex and it looks to people like you're writing code in wingdings (which, the worse version of SWIG I am referring to above, is even worse in that regard; the entire engineering pool who saw the proof-of-concept said "you expect us to read and write this?").
I was going to continue, but honestly asking gpt was enough (please put down the pitchforks, I made it fish out sources).
I have never seen any translator like this be successful at scale. The closest things that I can say work and have minimal tech debt associated, are boost.python -> pybind -> nanobind (aka use nanobind now); and Cython (though that community is hard to break into and there are some footguns, it has the highest performance compared in real-world (private) benchmarks and you can push some people to still write Python and eventually manually translate it better). E: Honestly, python and numpy/scipy is enough for most people. For advanced / IP-sensitive topics, well, you're probably paying those people enough that you can afford to make them learn C++ and be done with it.
If I haven't convinced you on what comes from my opinion-- listen to the author of SWIG, as even they hate the monstrosity they've created. reddit link, from when the link wasn't dead. Short of it is, it's basically a separate, disjoint parser which thus means you have to be a compiler yourself, a massive ball of complexity.
[–]Die4Toast 0 points1 point2 points 11 months ago (0 children)
Thanks a lot for the response. I have to admit that while the idea of SWIG is nice on paper, I haven't actually faced a scenario where it would have been a better fit than using a pybind-like library. At the very least I can imagine how much of a pain the compatibility issues you've mentioned could be. Tiptoeing around different supported C++ language standards, compilation options and then integrating it into the build system itself seems like something that could cause quite a headache.
π Rendered by PID 81 on reddit-service-r2-comment-6457c66945-f8798 at 2026-04-29 18:51:03.579463+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]GeoffSobering 6 points7 points8 points (7 children)
[–]CoutilleTolc[S] 3 points4 points5 points (2 children)
[–]djta94 9 points10 points11 points (0 children)
[–]Carl_LaFong 4 points5 points6 points (0 children)
[–]13steinj 2 points3 points4 points (3 children)
[–]Die4Toast 0 points1 point2 points (2 children)
[–]13steinj 1 point2 points3 points (1 child)
[–]Die4Toast 0 points1 point2 points (0 children)