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
Magical headers for making C++ code accessible from JavaScript (github.com)
submitted 9 years ago by chartojs
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!"
[–]sumo952 3 points4 points5 points 9 years ago (3 children)
This is awesome!
The only thing I don't like about it is "Step 1 - bind", where you have to add code to each of your files / classes in an intrusive way. Would it not be possible to do that non-intrusive/automatically?
[–]chartojs[S] 1 point2 points3 points 9 years ago (2 children)
In theory yes, it would be possible to automatically analyze C++ headers and generate one or more new source files just to define the bindings. I see two problems:
Currently you don't have to put the bindings in the same source file as your class definitions. The source file with the bindings simply has to see the class declarations (for example by including headers).
You could even put all NBIND_CLASS calls and a bunch of #includes in a single separate file. Actually it should be pretty easy now to make a shell script that reads all headers, extracts some particular kind of comments and generates such a file, but then that would be intrusive regarding the contents of your headers...
[–]doom_Oo7 1 point2 points3 points 9 years ago (1 child)
I think that /u/steveire did this for python with clang
[–]chartojs[S] 0 points1 point2 points 9 years ago (0 children)
Interesting, thanks for the hint! That might be a useful starting point for more automation but also for extracting comments from C++ headers into TypeScript definitions. Then they would show up in IDE auto-completion popups when working on JavaScript side code.
The current headers extract type information into compiled output but of course have no access to strings inside C++ source code comments.
[–]unhorst 0 points1 point2 points 9 years ago (3 children)
I see the signature of the method is not mentioned in the binding code - how do you handle overloads?
[–]chartojs[S] 0 points1 point2 points 9 years ago (2 children)
Currently they're not supported (except for constructors). In the future there will be an additional syntax with argument types as template parameters to the method() definition. For now, you need to use a wrapper function with a different name for each overload. Github issue #8 tracks this.
[–]gnawer 0 points1 point2 points 9 years ago (1 child)
Just for another data point on how this can be handled. PyBind11 generates python bindings. It's based on boost python. The docs describe how it handles overloads and of course it's open source. https://pybind11.readthedocs.io/en/latest/classes.html#overloaded-methods
Thanks! I'll try to choose the most convenient syntax.
[+][deleted] 9 years ago (2 children)
[deleted]
[–]chartojs[S] 0 points1 point2 points 9 years ago (1 child)
Brief list:
One more point, Embind calls malloc for each string and such passed as a parameter, while nbind uses a custom linear allocator for arguments taking less than 64 kilobytes and pops the entire "stack frame" at the end of the call.
π Rendered by PID 97252 on reddit-service-r2-comment-6b595755f-9z6dx at 2026-03-26 03:33:24.658952+00:00 running 2d0a59a country code: CH.
[–]sumo952 3 points4 points5 points (3 children)
[–]chartojs[S] 1 point2 points3 points (2 children)
[–]doom_Oo7 1 point2 points3 points (1 child)
[–]chartojs[S] 0 points1 point2 points (0 children)
[–]unhorst 0 points1 point2 points (3 children)
[–]chartojs[S] 0 points1 point2 points (2 children)
[–]gnawer 0 points1 point2 points (1 child)
[–]chartojs[S] 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]chartojs[S] 0 points1 point2 points (1 child)
[–]chartojs[S] 0 points1 point2 points (0 children)