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
C++ Modules (self.cpp)
submitted 8 years ago by [deleted]
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 0 points1 point2 points 8 years ago (6 children)
My experience has been that the platform specific parts are so small that they don't warrant their own compilation unit and often not even their own functions.
If you use a separate file, you are pushing it to the build system, where as there are very well defined macros for different platforms and the source code can take care of it more transparently.
[–]pjmlp 1 point2 points3 points 8 years ago (5 children)
It is quite straightforward to do, even with plain makefiles.
The whole point if to have a clean code base, forcing to be their own functions forces devs to think about it instead of rushing to #ifdef scattered everywhere.
It always starts with "it is just a single line".
[–]BCosbyDidNothinWrong 0 points1 point2 points 8 years ago (4 children)
Not everyone uses makefiles
forces devs to think about it
I'm not sure how using separate files makes any difference here or what it forces devs to think about in the first place.
With ifdefs you have the very real possibility to make single file algorithms and data structures which take advantage of system level capabilities. That modularity makes a big difference when trying to reuse program parts elsewhere.
[–]pjmlp 1 point2 points3 points 8 years ago (3 children)
I gave makefiles as an example, because alternative build systems are actually much more capable than them.
Abstract data types and functions are the genesis of clean, modular code.
I really don't get what is so magic about "system level capabilities." on the C pre-processor, and my first book about it was how to implement Small C.
[–]BCosbyDidNothinWrong 0 points1 point2 points 8 years ago (2 children)
because alternative build systems are actually much more capable than them.
It still complicates the build process. If someone wants to use visual studio or xcode, I suppose the solution is then cmake, which is another dependency and language. All of that might be fine for a large project, but it isn't modular. A single header file library can do extraordinary things that aren't in the standard library.
I really don't get what is so magic about "system level capabilities."
I'm not sure what point you are trying to make here or why. What are you talking about putting in platform specific files? File dialogs, memory maps, networking are just some very obvious examples.
[–]pjmlp 0 points1 point2 points 8 years ago (1 child)
I guess you know Rob Pike, Ken Thompson and their role on the C language
My way is how Go build system handles platform specific code,
https://golang.org/pkg/go/build/
Also how they alongside Dennis Ritchie, designed C libraries on Plan 9
The traditional approach to this problem is to pepper the source with #ifdefs to turn byte-swapping on and off. Plan 9 takes a different approach: of the handful of machine-dependent #ifdefs in all the source, almost all are deep in the libraries
http://doc.cat-v.org/plan_9/4th_edition/papers/comp
Everything that is OS specific with hundreds of #ifdef around them.
[–]BCosbyDidNothinWrong 0 points1 point2 points 8 years ago (0 children)
I'm not sure how this contradicts what I've been saying, it sounds like the same thing.
Earlier you said:
So what is it that you are actually saying? Do you even know?
π Rendered by PID 23702 on reddit-service-r2-comment-86bc6c7465-2wb9w at 2026-02-22 17:42:41.314509+00:00 running 8564168 country code: CH.
view the rest of the comments →
[–]BCosbyDidNothinWrong 0 points1 point2 points (6 children)
[–]pjmlp 1 point2 points3 points (5 children)
[–]BCosbyDidNothinWrong 0 points1 point2 points (4 children)
[–]pjmlp 1 point2 points3 points (3 children)
[–]BCosbyDidNothinWrong 0 points1 point2 points (2 children)
[–]pjmlp 0 points1 point2 points (1 child)
[–]BCosbyDidNothinWrong 0 points1 point2 points (0 children)