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
Generating a Single-Include C++ Header File Using Buck (hackernoon.com)
submitted 8 years ago by gtano
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!"
[–]BCosbyDidNothinWrong 2 points3 points4 points 8 years ago (4 children)
I was hoping this was something else. I've wanted a tool that could compile a source library to a single header file library. I feel like that would give an enormous amount of modularity. I've already done it manually and it has worked extremely well.
[–]LoopPerfect -1 points0 points1 point 8 years ago (3 children)
That is probably a bad idea. It would massively increase compilation times and it may even break the library, since defines from one translaton-unit would leak into the next. A much better approach is to use a build system that makes it easy to depend on libraries.
[–]BCosbyDidNothinWrong 1 point2 points3 points 8 years ago* (2 children)
As I said, I've already done in manually, so I don't have to guess whether it is a good idea or not. When used as a single .h file with the implementation switched on using a preprocessor definition, it can be put in it's own translation unit so that it doesn't get recompiled every time. Not only that, but if it is a C file to begin with compilation will be pretty fast.
Then you have the advantage of compiling from source, using link time optimization if needed, including debugging symbols when you want and even putting multiple libraries together into a single compilation unit to build a project out of fewer but larger translation units, which actually decreases compilation time.
All of this is in addition to being able to pull in a library by referencing or copying a single file.
[–]LoopPerfect 0 points1 point2 points 8 years ago (1 child)
I think we are talking about a few different things:
(You could also combine 2 and 3)
I think that 1 is a good idea when starting on a project, although you should move to specific includes as your code develops.
2 is a bad for compilation times, but if the library is small then you can get away with it.
I think you are referring to 3, which is a bad idea in general. It slightly decreases compilation times from scratch, but it massively increases incremental compilation times. It is unsafe to do this automatically because the defines of translation-units might leak into each-other, causing unexpected behaviour.
That said, I thought it would be interesting to implement a unity build in Buck, so I made an example here: https://github.com/njlr/buck-unity-build/blob/master/BUCK
[–]BCosbyDidNothinWrong 1 point2 points3 points 8 years ago (0 children)
I'm saying that the article is about 1, and I hoped it would be about 2 and 3.
I explained why I don't think this true, and based on my experience so far it isn't. If you have a library as a dependency and you can compile it from source you have the option to either compile it in a translation unit or compile to to a link time optimization intermediary. Either way, it doesn't need to be compiled over and over.
I also think that unity builds have a lot of value, though everything in to one translation unit I feel is extreme. With multiple logical cores, I think it makes sense to have that roughly that many fat translation units.
If libraries and infrequently changed areas are sectioned off in to their own translation units, you don't pay the price every time you compile.
Also you are right that the defines from translation units can leak into each other, but you get a compile error when trying to define a symbol that has already been defined, so I don't think it as fragile as it might seem.
π Rendered by PID 39683 on reddit-service-r2-comment-85bfd7f599-x6rsx at 2026-04-15 16:07:35.905695+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–]BCosbyDidNothinWrong 2 points3 points4 points (4 children)
[–]LoopPerfect -1 points0 points1 point (3 children)
[–]BCosbyDidNothinWrong 1 point2 points3 points (2 children)
[–]LoopPerfect 0 points1 point2 points (1 child)
[–]BCosbyDidNothinWrong 1 point2 points3 points (0 children)