r/cpp • • Aug 29 '20

Matplot++: A C++ Graphics Library for Data Visualization

571 Upvotes

Data visualization can help programmers and scientists identify trends in their data and efficiently communicate these results with their peers. Modern C++ is being used for a variety of scientific applications, and this environment can benefit considerably from graphics libraries that attend the typical design goals toward scientific data visualization. Besides the option of exporting results to other environments, the customary alternatives in C++ are either non-dedicated libraries that depend on existing user interfaces or bindings to other languages. Matplot++ is a graphics library for data visualization that provides interactive plotting, means for exporting plots in high-quality formats for scientific publications, a compact syntax consistent with similar libraries, dozens of plot categories with specialized algorithms, multiple coding styles, and supports generic backends.

https://github.com/alandefreitas/matplotplusplus


r/cpp • • May 22 '22

Compiler Explorer is 10 today!

Thumbnail
xania.org
548 Upvotes

r/cpp • • Aug 15 '20

Why has reddit suspended Bjarne Stroustrup's account? Accounts are only suspended manually so somebody at reddit looked at u/bstroustrup's account and decided to suspend it.

Thumbnail reddit.com
537 Upvotes

r/cpp • • Oct 16 '23

WTF is std::copyable_function? Has the committee lost its mind?

533 Upvotes

So instead of changing the semantics of std::function the committee is introducing a new type that is now supposed to replace std::function everywhere? WTF

So now instead of teaching beginners to use std::function if they need a function wrapper, they should be using std::copyable_function instead because it's better in every way? This is insane. Overcomplicating the language like that is crazy. Please just break backwards compatibility instead. We really don't need two function types that do almost the same thing. Especially if the one with the obvious name is not the recommended one.


r/cpp • • Mar 24 '22

IDE-style autocomplete for your terminal that integrates with C++ tools (clang, gcc)

532 Upvotes

r/cpp • • Dec 26 '23

Whatโ€™s the best naming prefix for a global variable?

531 Upvotes

Answer: //


r/cpp • • Nov 18 '18

Set of C++ programs that demonstrate hardware effects (false sharing, cache latency etc.)

531 Upvotes

I created a repository with small set of self-contained C++ programs that try to demonstrate various hardware effects that might affect program performance. These effects may be hard to explain without the knowledge of how the hardware works. I wanted to have a testbed where these effects can be easily tested and benchmarked.

Each program should demonstrate some slowdown/speedup caused by a hardware effect (for example false sharing).

https://github.com/kobzol/hardware-effects

Currently the following effects are demonstrated:

  • bandwidth saturation

  • branch misprediction

  • branch target misprediction

  • cache aliasing

  • memory hierarchy bandwidth

  • memory latency cost

  • non-temporal stores

  • data dependencies

  • false sharing

  • hardware prefetching

  • software prefetching

  • write combining buffers

I also provide simple Python scripts that measure the program's execution time with various configurations and plot them.

I'd be happy to get some feedback on this. If you have another interesting effect that could be demonstrated or if you find that my explanation of a program's slowdown is wrong, please let me know.


r/cpp • • Sep 16 '23

I was a god today

524 Upvotes

So I have come back to my project after a few years, made some big changes and was ready to release. As usual time to run it with the sanitizers and I just can't get ASAN to work. Ok no problem, sit back and do some simple samples and see why cmake isn't turning it on, check compile_comands, etc... Why. Is. It. Not. Working!!!

Then it dawned on me, that I am possibly a god. That I am finally 'good' at c++, and join the promised land, the happy hunting grounds of the heros of the 90s and 2000s. I created a raw leak with a 'new' expression (oh boy look at that dirty expression, we have come so far) and boom ASAN was printing errors. My project just had no problems because old me had produced good enough c++ code to branch off years later. I'm not green, still perhaps I missed something, but at the moment I am convinced all-father bjarne awaits me in valgrindhalla.

Edit: In seriousness, the sanitizers could just spit out some information at the start and all this would have been avoided.


r/cpp • • Apr 15 '26

YAY!!! Announcement: cppreference.com update

Thumbnail isocpp.org
522 Upvotes

This is not my post, but I didn't see anyone share this here yet.


r/cpp • • Jan 10 '22

In 10 years, Clang has become 2x slower, but generates code that is 10-20% faster

Thumbnail zeux.io
508 Upvotes

r/cpp • • May 30 '22

I enjoy the weird and arcane corners of C++ so I made a list in the form of an "iceberg meme", as a tribute to some obscure and lesser known quirks of the language.

Thumbnail fouronnes.github.io
504 Upvotes

r/cpp • • Sep 14 '21

The relationship between C++ and Psychopathy

497 Upvotes

I decided to take a C++ course in uni this semester. And the only thing I'm sure is that, either

  1. C++ is a language for psychopaths.

  2. My C++ professor in particular is a psychopath.

I'd love to get some input from you guys in order to understand which is correct.

So, basically: C++ is a course called Programming III. Programming I and II (C and Java, respectively) were an absolute piece of cake. C++, though... I'm really struggling to get by. There's just too much. Templates, copy constructors, destructors, copy assignment, templates, pointers, custom operators, type_traits, templates, weird lambdas, templates, templates, and it goes on.

The assignments basically require me to customize every single operator, 3 differently templated overloads of methods, etc, etc. Some examples of the stuff we had to do: create a "var" class that behaves exactly as you would expect. Recreate the Vector class with some retarded stuff like creating a ** operator for cross product (and no, this operator doesn't happen to exist). And a lot of code that looks like this:

template <typename T, template <typename> class Custom = vector, typename F>
auto operator & ( const Custom<T> &vec, F func ) {
    if constexpr ( is_same_v<invoke_result_t<decltype(func), decltype(*vec.begin())>, bool>){
        //...
    }
}

Everything I write sounds like a horrible mistake. These kinds of templates make me feel like I'm using nonsense hacks in a dynamically-typed language. Custom operators sound like a terrible practice to me, you never know if the operator of a certain class has been modified or not, and how it's supposed to behave. Etc, etc.

My question is simple: is this actually used on a daily basis by your average C++ developer, or am I being taught rocket science for no reason?

Edit: Thanks a lot for the feedback! I might not be able to reply to all of you, but I really appreciate your answers.

And by the way, just clarifying! Don't take the title too seriously, I'm not trying to offend anyone, it's just a little joke. And in fact, this professor is one of the best I've had so far - it's just that the assignments have been significantly harder than I expected.


r/cpp • • Jul 17 '20

A day in the life of a C++ compiler developer

Thumbnail
twitter.com
494 Upvotes

r/cpp • • Feb 20 '24

CMake is the perfect build tool for C++.

490 Upvotes
  • Both CMake and C++ have 'legacy' and 'modern' syntax and semantics.

  • Both CMake and C++ haven't officially gotten rid of their 'legacy' features, leading to footguns that are easily triggered by new-ish developers.

  • Both CMake and C++ don't really have good up-front example-driven documentation, and would rather users read reference-style documentation or massive textbooks, and guess what should be written, instead of outright recommending certain practices.

  • Both CMake and C++ have decent performance, but at a fairly high syntax and semantic complexity.

  • Both CMake and C++ are simultaneously hated and beloved by their users, who generally develop Stockholm syndrome over both languages.

  • Both CMake and C++ attempt to have nice type and data manipulation, but can't escape their string-typed legacies.

CMake and C++ are made for each other.


CMake's handling of if is by far the biggest WTF moment I have experienced.


EDIT: this is a mostly joke post. I use CMake extensively and almost exclusively, and I think it's pretty good. It's not great, nor perfect, but it's good.


r/cpp • • Jul 20 '19

2019-07 Cologne ISO C++ Committee Trip Report โ€” ๐Ÿš€ The C++20 Eagle has Landed ๐Ÿš€ (C++20 Committee Draft shipped; Contracts Moved From C++20 to a Study Group; `std::format` in C++20; C++20 Synchronization Library)

490 Upvotes

The ISO C++ Committee met in Cologne ๐Ÿป ๐Ÿ‡ฉ๐Ÿ‡ช last week to complete and publish the Committee Draft (CD) of the next International Standard (IS), C++20. Between now and the next meeting, we will send the Committee Draft to all the national standards bodies and collect their feedback. In the next two meetings, we'll respond to their comments, and then publish the C++20 International Standard at the February 2020 meeting in Prague ๐Ÿ‡จ๐Ÿ‡ฟ.

ย 

This week, we made the following changes and additions to the C++20 draft:

ย 

The following notable features have been approved for C++20 at prior meetings:

ย 

C++20, the most impactful revision of C++ in a decade, is now feature complete. Our 3-year release cycle is paying off.

ย 


Contracts


We made the decision this week to move contracts out of C++20 (see P1823, although it is not publicly available as of the time of this post).

Why take contracts out?

  • We have made major design changes to contracts very late in the C++20 process, including at this meeting (see the many recent papers).

  • We were not confident on the impact or implications of these changes.

  • We have insufficient implementation and usage experience with contracts.

  • We have concerns that the changes artificially limited future directions.

In short, contracts were just not ready. It's better for us to ship contracts in a form that better addresses the use cases of interest in a future standard instead of shipping something we are uncertain about in C++20. Notably, this decision was unanimous -- all of contractsโ€™ co-authors agreed to this approach.

We've created a new study group, SG21, to continue work on contracts, which will be chaired by John Spicer, which includes all original authors, as well as many new interested members. All feedback was this feature is highly desirable, will provide a lot of value to a lot of users, and SG21 is committed to delivering that as soon as itโ€™s ready.

ย 


Language Progress


Evolution Working Group Incubator (EWGI) Progress


The Evolution WG Incubator (EWGI) saw all papers which were ready to be seen over two days, for a total of 18 papers:

There are 9 papers which were seen in a previous meeting, which we did not see because we're waiting for updates. Two other papers did not have presenters available this week, we'll try to see them in Belfast. Finally, one paper dropped from our schedule due to an unreachable author.


Evolution Working Group (EWG) Progress


Evolution met this week to finalize C++20's language features. We worked on the following:

  • Permit unevaluated inline asm in constexpr (approved as a part of C++20)

  • [[nodiscard]] for constructors (made retroactively applicable to C++17)

  • Removed pack support in expansion statements due to discovered ambiguity. You can now only iterate over tuple-like and range-like. Since you cannot iterate over packs, the spelling of for... no longer made any sense and was changed to template for

  • Discussed static, value-based exceptions and encouraged further work on the paper, but discouraged work on try-expressions.

  • Removed requires expressions of the form -> Type, as they donโ€™t entirely match other parts of the language and the functionality can be entirely subsumed by whichever of -> same_as<Type> or -> convertible_to<Type> is actually intended by the concept author.

  • Encouraged further work on simplifying all the name lookup rules in an attempt to remove all the various exceptions and special-cases.

ย 


Library Progress


Library Evolution Working Group Incubator (LEWGI) Progress


The Library Evolution Incubator met for 3ยฝ days this week, and looked at 35 papers targeting C++23, future TSes, and beyond.

We saw the following notable papers this week:

  • Process Management Library - We liked this proposal, and gave the authors guidance on which features to focus on for a minimal version 1.

  • Compositional Numeric Types for a Numerics Technical Specification - We've seen this proposal (and other related ones) before; hopefully it will be headed to a Technical Specification soon!

  • Low Level I/O Library - We haven't decided if we want to pursue this yet; we'll look at it more at the next meeting.

  • std::web_view - We liked this proposal as a solution for providing a modern UI library in the C++ standard; we'll look at it in more detail at the next meeting.

  • Linear Algebra - We looked through the proposal for a linear algebra library based on BLAS and gave the authors some design feedback; this proposal is still young, so we'll see it again in the future.

Happy Birthday Bryce! ๐ŸŽ‚


Library Evolution Working Group (LEWG) Progress


This week LEWG polished the C++ standard library features, processing bugfixes for std::format and std::ranges.

LEWG met together with the concept authors to discuss the renaming from PascalCase to snake_case. We had the unique opportunity to revisit all the names and improve them, developing guidelines for naming to prevent name clashes between concepts and types. As a consequence, the namespace std::ranges::view/ std::view was renamed to std::ranges::views/std::views to free up the name for the View (now std::ranges::view) concept.

C++20 will also now have access to the ฯ€ constant and friends, available as std::numbers::pi in <numbers>.

Finally, LEWG started looking at C++23 features. The focus will be on an executors and a better std::error_code, both in preparation for networking. As part of error management, LEWG started to discuss the handling of allocation failures.

We're also spinning up an effort to conduct an inter-meeting review of the Networking Technical Specification to figure out how to modernize it and proceed with it.


Library Wording Group (LWG) Progress


The library group was extremely busy reviewing many papers targeting C++20, and managed to land many of the big papers, such as std::format, the C++20 Synchronization Library, std::jthread, and constexpr all the things.

What happened to my favorite library feature not listed?

Unfortunately, the group was unable to review all papers that Library Evolution approved for C++20, which means they won't make it in.

ย 


Concurrency and Parallelism Study Group (SG1) Progress


Most of the concurrency & parallelism features for C++20 were actually applied to the Standard at this meeting.

That includes: semaphores (binary and counting), latches, barriers, efficient polling (wait and notify - think: like Futex), the joining thread and its stop token. We did some preventive maintenance in this release also, such as cleanups to release sequences (interact with consume) and volatile (parts of which never worked well).

Weโ€™re looking to the future projects now. Up next will be the Concurrency TS2, for which weโ€™ve chosen a scope: concurrent deferred memory reclamation and fibers.

Executors progressed significantly at this meeting. There is now a CONSENSUS (!) design on everything except error handling, and a few TODOs on reconciling bulk executors with the latest changes. This should signal the end of the project slip that began with the Rapperswil meeting, 1 year ago, with the end now in sight.

Finally, so many memory model experts were in attendance! We used this opportunity to process memory model extensions for an entire day.

ย 


Compile Time Programming and Reflection Study Group (SG7) Progress


We discussed the constexpr based reflection proposal containing novel requires syntax for compile-time value based function overloading. The language feature was sent towards EWG and the authors were encouraged to continue developing a value-based reflection API based on this technique.

We also looked at updates of metaclass paper. At the end of the session we discussed the future of the compile-time metaprogramming in C++ and the proposed code-injection syntax.

ย 


Undefined Behavior Study Group (SG12)/Vulnerabilities Working Group (WG23) Progress


SG12 and WG23 met this week to continue work on their efforts to document vulnerabilities in the C++ programming language.

We also reviewed a number of papers relating to Undefined Behavior:

Finally, weโ€™re extremely interested in the proposal to enumerate language Undefined Behavior.

ย 


Human Machine Interface and Input/Output Study Group (SG13) Progress


SG13 met for two afternoons this week, and reviewed 3 major proposals:

ย 


Tooling Study Group (SG15) Progress


This week, the Evolution Working Group (EWG) agreed to begin work on a C++ Modules Ecosystem Technical Report, to prepare the C++ community for the transition to C++20 Modules..

SG15 has been very busy since the last meeting, holding eight telecons to work on content for the C++ Modules Ecosystem Technical Report.

We also met for a full day at Cologne, discussing 7 papers for the Technical Report, most notably a proposal on the build system ecosystem and build system interchange and a proposed file format for describing dependencies, which we had consensus to use as the basis for addressing build systems and packaging.

We reached two key conclusions about what content we want in the Technical Report:

  • We want to recommend module naming conventions, but not project structure, file naming conventions, or namespace naming conventions.

  • We want recommendations for implicit builds of modules which do not prescribe a particular project layout or file naming scheme.

ย 


Unicode and Text Study Group (SG16) Progress


SG16 reviewed 7 papers at this meeting, all targeting a post-C++20 revision of the standard. Two of these papers directly target text processing. For the others, we provided guidance to the paper authors regarding handling of Unicode, character encodings, and file names (since file names do not have associated portable character encodings in general, they are challenging to handle accurately, particularly in text processing).

Standard Text Encoding is exploring new interfaces for transcoding text between various encodings. This is important foundational work necessary to add further Unicode support.

Text Parsing proposes a type-safe and extensible replacement for sscanf, similarly to how std::format is a type-safe replacement for sprintf.

The papers we provided guidance on include proposals for a std::filesystem::path_view class, new process creation interface, 2D graphics support, a file format for describing dependencies, and a paper advising against teaching beginner programmers to use char8_t until more support for this new builtin type is available. Some of these reviews were a collaboration with SG13 (HMI/IO) and SG20 (Education). We enjoyed working with our fellow study groups!

ย 


Education Study Group (SG20) Progress


SG20 met for a day to continue discussing the formation of curriculum guidelines. We reviewed five papers, four of which target an earlier proposal, the guidelines for teaching C++ to beginners, and one that looks to introduce a new idiom for teaching and safety-critical programming. Itโ€™s important to recall that the work that leaves SG20 wonโ€™t be included in a C++ standard; itโ€™ll instead be included in a different medium.

The group reviewed Don't use char8_t and std::u8string yet in P1389, and agreed that while teaching students to appreciate UTF-8 string-handling is important, itโ€™s best to hold off until C++ has UTF-8 string-handling support.

We then looked at Fill in [delay.cpp] TODO in P1389, where we agreed that P1389 should adopt recommendations to delay teaching macros until absolutely necessary, and should be integrated into the guidelines.

We encouraged the author of Class Natures for Safety Critical Code: On user-declared and user-defined special member functions to continue working on their proposal, for further consideration in the Belfast meeting.

We finally reviewed Modular Topic Design, which proposes that we replace the rigid stage-based design in P1389 with a far more modular sets of topics. We encouraged the author to continue working on their proposal for further consideration in Belfast.

ย 


C++ Release Schedule


We've scheduled two additional meetings between now and the next full committee meeting to work on specific parts of C++20.

NOTE: This is a plan not a promise. Treat it as speculative and tentative. See P1000 for the latest plan.

  • IS = International Standard. The C++ programming language. C++11, C++14, C++17, etc.

  • TS = Technical Specification. "Feature branches" available on some but not all implementations. Coroutines TS v1, Modules TS v1, etc.

  • CD = Committee Draft. A draft of an IS/TS that is sent out to national standards bodies for review and feedback ("beta testing").

MeetingLocationObjective
2017 Summer MeetingToronto ๐Ÿ‡จ๐Ÿ‡ฆFirst meeting of C++20.
2017 Fall MeetingAlbuquerque ๐Ÿ‡บ๐Ÿ‡ธDesign major C++20 features.
2018 Spring MeetingJacksonville ๐Ÿ‡บ๐Ÿ‡ธDesign major C++20 features.
2018 Summer MeetingRapperswil ๐Ÿ‡จ๐Ÿ‡ญDesign major C++20 features.
2018 Summer LWG MeetingChicago ๐Ÿ‡บ๐Ÿ‡ธWork on wording for C++20 features.
2018 Fall EWG Modules MeetingSeattle ๐Ÿ‡บ๐Ÿ‡ธDesign modules for C++20.
2018 Fall LEWG/SG1 Executors MeetingSeattle ๐Ÿ‡บ๐Ÿ‡ธDesign executors for C++20.
2018 Fall MeetingSan Diego ๐Ÿ‡บ๐Ÿ‡ธC++20 major language feature freeze.
2019 Spring MeetingKona ๐Ÿ„โ€โ™‚๏ธ ๐ŸŒŠ ๐Ÿ‡บ๐Ÿ‡ธC++20 feature freeze. C++20 design is feature-complete.
2019 Summer MeetingCologne ๐Ÿป ๐Ÿ‡ฉ๐Ÿ‡ชComplete CD wording. Start CD balloting ("beta testing").
2019 Fall MeetingBelfast ๐Ÿ‡ฌ๐Ÿ‡งCD ballot comment resolution ("bug fixes").
2020 Spring MeetingPrague ๐Ÿ‡จ๐Ÿ‡ฟCD ballot comment resolution ("bug fixes"), C++20 completed.
2020 Summer MeetingVarna ๐Ÿ‡ง๐Ÿ‡ฌFirst meeting of C++23.
2020 Fall MeetingNew York (Tentative) ๐Ÿ‡บ๐Ÿ‡ธDesign major C++23 features.
2021 Winter MeetingKona ๐Ÿ„โ€โ™‚๏ธ ๐ŸŒŠ ๐Ÿ‡บ๐Ÿ‡ธDesign major C++23 features.
2021 Summer Meeting๐Ÿ—บ๏ธDesign major C++23 features.
2021 Fall Meeting๐Ÿ—บ๏ธC++23 major language feature freeze.
2022 Spring Meeting๐Ÿ—บ๏ธC++23 feature freeze. C++23 design is feature-complete.

ย 


Status of Major C++ Feature Development


NOTE: This is a plan not a promise. Treat it as speculative and tentative.

  • IS = International Standard. The C++ programming language. C++11, C++14, C++17, etc.

  • TS = Technical Specification. "Feature branches" available on some but not all implementations. Coroutines TS v1, Modules TS v1, etc.

  • CD = Committee Draft. A draft of an IS/TS that is sent out to national standards bodies for review and feedback ("beta testing").

Changes since last meeting are in bold.

FeatureStatusDepends OnCurrent Target (Conservative Estimate)Current Target (Optimistic Estimate)
ConceptsConcepts TS v1 published and merged into C++20C++20C++20
RangesRanges TS v1 published and merged into C++20ConceptsC++20C++20
ModulesMerged design approved for C++20C++20C++20
CoroutinesCoroutines TS v1 published and merged into C++20C++20C++20
ExecutorsNew compromise design approved for C++23C++26C++23
ContractsMoved to Study GroupC++26C++23
NetworkingNetworking TS v1 publishedExecutorsC++26C++23
ReflectionReflection TS v1 publishedC++26C++23
Pattern MatchingC++26C++23

ย 

Last Meeting's Reddit Trip Report.

ย 

If you have any questions, ask them in this thread!

ย 

ย 

/u/blelbach, Tooling (SG15) Chair, Library Evolution Incubator (SG18) Chair

/u/bigcheesegs

/u/c0r3ntin

/u/jfbastien, Evolution Incubator (SG17) Chair

/u/arkethos (aka code_report)

/u/foonathan

/u/vulder

/u/hanickadot

/u/tahonermann, Text and Unicode (SG16) Chair

/u/cjdb-ns, Education (SG20) Lieutenant

/u/nliber

/u/sphere991

/u/tituswinters, Library Evolution Working Group (LEWG) Chair

/u/HalFinkel, Vice Chair of PL22.16

/u/ErichKeane

/u/sempuki

/u/ckennelly

/u/mathstuf

โ‹ฏ and others โ‹ฏ


r/cpp • • Jul 19 '21

I forked Crow, an abandoned C++ Web Framework. And I'm currently maintaining it.

489 Upvotes

Last year I was looking to port a Flask REST API I made to C++ because speed and why not. I went through a few C++ frameworks but eventually chose the abandoned since 2017 Crow. It was by far the easiest to set up and work with (being inspired by Flask in the first place), and it didn't hurt that it supported Websockets.

Between wanting to contribute to this gem I found and wanting to learn C++, I decided to try to add some features. almost 1 year, a crapton of every skill I possessed, and a lot of help from people who shared my passion. And I'm now looking at taking this project into a production environment.

So much has been fixed/improved/added, so if anyone here is interested in making a new web service or changing their existing one, feel free to check out this fork of Crow.


r/cpp • • Nov 11 '24

Herb Sutter leaves Microsoft for Citadel

486 Upvotes

r/cpp • • Aug 27 '21

Compiler Explorer now supports multiple file compilation and linking

Thumbnail
godbolt.org
484 Upvotes

r/cpp • • Apr 07 '19

A pretty big list of C++ GUI libraries

483 Upvotes

So I have to choose a UI library for my game engine. Since I won't use popular options, I went down a rabbit hole looking for libraries. I thought there weren't many GUI solutions for C++, I was quite wrong. The result is a list of 35 "healthy" C++ UI libraries.

I also ended up unearthing a bunch of old, dead UI libraries. It is quite entertaining to go back memory lane.

I've compiled the libraries here with screenshots, short descriptions and pros/cons I could quickly gather. Let me know if I missed anything (alive or dead)!

Here is the list of healthy projects I could find, Cheers.


r/cpp • • Apr 10 '19

C++ might have saved my career.

481 Upvotes

I never really was comfortable with programming, along with other personal issues it was all hard to actually improve my skills at all.

I've always read and was told that C/C++ was old and out of date and to not waste my time learning it. Well I understand why people are scared of this language; but man has it helped me understand programming on a whole other level. Im not going to say I can professionally program a C++ project but I definitely feel more confident in my programming in C# and other languages for work.

I think I found my passion because of this subreddit and I would like to think you all. Being closer to the computer is where I think I want to be and even though it's a scary path what the hell it is fun doing it, it's like a roller coaster ride. :P


r/cpp • • May 24 '20

Analyzing The Simplest C++ Program

Thumbnail
oneraynyday.github.io
480 Upvotes

r/cpp • • Aug 07 '25

I wrote a comprehensive guide to modern CMake using a real 80-file game engine project (not another hello-world tutorial)

474 Upvotes

After struggling with CMake on my game engine project for months, I decided to document everything I learned about building professional C++ build systems.

Most CMake tutorials show you toy examples with 2-3 files. This guide uses aย complex projectย - my ColumbaEngine, an open source c++ game engine ([github](https://github.com/Gallasko/ColumbaEngine)) with 80+ source files, cross-platform support (Windows/Linux/Web), complex dependencies (SDL2, OpenGL, FreeType), and professional distribution.

Part 1 covers the compilation side:

  • Modern target-based CMake (no more global variables!)

  • Dependency management strategies (vendoring vs package managers vs FetchContent)

  • Cross-platform builds including Emscripten for web

  • Precompiled headers that cut build times by 60%

  • Generator expressions and proper PUBLIC/PRIVATE scoping

  • Testing infrastructure with GoogleTest

The examples are all from production code that actually works, not contrived demos.

https://medium.com/@pigeoncodeur/cmake-for-complex-projects-part-1-building-a-c-game-engine-from-scratch-for-desktop-and-774426c5f1f7

Part 2 (coming soon) will cover installation, packaging, and distribution - the stuff most tutorials skip but is crucial for real projects.

Hope this helps other developers dealing with complex C++ builds! Happy to answer questions about specific CMake pain points.


r/cpp • • Oct 28 '22

Bjarne Appreciation Post

474 Upvotes

I just saw that Bjarne posted to this subreddit so I wanted to take a moment to thank him on behalf of this whole subreddit and maybe he will see it.

Thank you Bjarne!

Thank you for all of your work and commitment to C++. Thanks for making my life and the lives of millions of C++ developer easier and more productive. Thank you for showing such passion and dedication to this wonderful field.

Thank you for answering questions and giving talks and taking the time to educate everyone in this community. We wouldn't be the same without you.


r/cpp • • Nov 09 '23

Questions from one job interview on C++ developer

471 Upvotes

Two days ago I passed job interview on C++ developer. Here I would like to share questions I was asked on this interview. Hope it will be useful for community.

I have grouped questions by topic.

C++ basics:

  • Difference between references and pointers?

  • Difference btw memory allocation in stack and on heap?

  • What kinds of smart points do exist?

  • How unique_ptr is implemented? How do we force that only one owner of the object exist in - unique_ptr ?

  • How does shared_ptr work? How reference counter is synchronized between objects?

  • Can we copy unique_ptr or pass it from one object to another?

  • what are rvalue and lvalue?

  • What are std::move and std::forward()

OOP:

  • Ways to access private fields of some class?

  • Can a class inherit multiple classes?

  • Is static field initialized in class constructor?

  • Can an exception be thrown in constructor / destructor? How to prevent that?

  • What are virtual methods?

  • Why do we need virtual destructor?

  • Difference between abstract class and interface?

  • Can be constructor virtual?

  • How keyword const is used for class methods?

  • How to protect object from copying?

STL containers:

  • -Difference between vector and list?

  • Difference between map and unordered map?

  • When calling push_back() make iterator in vector invalid?

  • How to modify your class to use with map and unordered_map?

Threads:

  • Difference between processes and threads?

  • Can the same thread be ran twise?

  • Ways to synchronize threads?

  • What is deadlock?