C++

1848 readers
10 users here now

The center for all discussion and news regarding C++.

Rules

founded 2 years ago
MODERATORS
1
 
 

It is now 45+ years since C++ was first conceived. As planned, it evolved to meet challenges, but many developers use C++ as if it was still the previous millennium. This is suboptimal from the perspective of ease of expressing ideas, performance, reliability, and maintainability. Here, I present the key concepts on which performant, type safe, and flexible C++ software can be built: resource management, life-time management, error-handling, modularity, and generic programming. At the end, I present ways to ensure that code is contemporary, rather than relying on outdated, unsafe, and hard-to-maintain techniques: guidelines and profiles.

2
 
 

I've tried a few tools like cloc to count the lines of code within my cpp project.

However, they are pretty surface level and just count the lines.

Is there anything that is able to show how many lines are for classe, imports, simple aliases, typedefs, and more detailed info like that.

My codebase is using C++ 20 modules and a lot of it is just imports and namespace aliases, so just counting the lines is pretty inaccurate. A lot of the files are simply just 10-20 lines at the header for imports, etc, and then just a small child class with constructors.

Which is to say that it's >50% "filler" in a lot of files.

If anyone knows any tools for this, ideally FOSS, please let me know. Thanks!

3
 
 

With P2900, we propose to add contract assertions to the C++ language. This proposal is in the final stages of wording review before being included in the draft Standard for C++26.

4
 
 

Full-text search engine for the C++ Working Draft (and older versions from Tim Song's repository)

5
13
Why I’m learning C++ (oldmoney.pattmayne.com)
submitted 2 months ago by [email protected] to c/[email protected]
6
 
 

(Only half joking with the poll options, too.)

7
 
 

On Saturday, the ISO C++ committee completed the third-last design meeting of C++26, held in Wrocław, Poland. There are just two meetings left before the C++26 feature freeze in June 2025, and C++26 is on track to be completed two more meetings after that in early 2026. Implementations are closely tracking draft C++26; GCC and Clang already support about two-thirds of C++26 features right now.

8
 
 

Hello C++ folks, i read this article about interoperability of those languages and wonder what is your opinion about interoperability initiatives.

Do you think it's a good opportunity to acquire Rust libraries and promote use of Cpp ones to a larger audience?

Or instead you think it's a crab conspiracy to promote RIIR (Rewrite It In Rust) strategy?

Thanks in advance

9
15
submitted 3 months ago* (last edited 3 months ago) by [email protected] to c/[email protected]
 
 

i've been playing with cppfront for a few minutes now and it's been a surprisingly pleasant experience so far. i'm tempted to try it out at work to see what happens, but i wanna know if anyone tried to use it in production and what your experiences are

for those who haven't heard of it, cppfront is a cpp2 to c++ compiler, a bit like coffeescript for js. cpp2 is herb sutter's proposal of a new and cleaner c++ syntax with better ergonomics, better orthogonality, and better defaults

10
 
 

First release of the checker against Google's style guide in over 2 years. Python 2 and 3.7 are no longer supported. Python 3.12 support was added along with fixed CI for 3.8. See CHANGELOG.rst for a full changelog, including quite a bit of features not mentioned here.

11
12
13
14
15
5
submitted 4 months ago* (last edited 4 months ago) by [email protected] to c/[email protected]
 
 

C++ programmer's guide to undefined behavior: part 6 of 11

https://pvs-studio.com/en/blog/posts/cpp/1163/

@cpp @cppguide

16
 
 

I just wanted to have a handy description of computed goto that I could refer to, to reuse this concept without having to read thousands of line trying to make sense out of it.

17
18
19
36
submitted 4 months ago* (last edited 4 months ago) by [email protected] to c/[email protected]
20
21
22
23
24
25
8
submitted 5 months ago* (last edited 5 months ago) by [email protected] to c/[email protected]
 
 

I created a little side project over the past few days, a new build system for C and C++: https://github.com/blueOkiris/acbs/

I've seen a lot of discourse over C build tools. None of them really seem solid except for (some) Makefiles (some Makefiles are atrocious; you just can't rely on people these days). Bazel, cmake - they're just not straight forward like a clean Makefile is, basically black magic, but setting up a Makefile from scratch is a skill. Many copy the same one over each time. Wouldn't it be nice if that Makefile didn't even need to be copied over?

Building C should be straight forward. Grab the C files and headers I want, set some flags, include some libraries, build, link. Instead project build systems are way way way overcomplicated! Like have you ever tried building any of Google's C projects? Nearly impossible to figure out and integrate with projects.

So I've designed a simplistic build system for C (also C++) that is basically set up to work like a normal Makefile with gcc but where you don't have to set it up each time. The only thing you are required to provide is the name of the binary (although you can override defaults for your project, and yes, not just binaries are possible but libs as well). It also includes things like delta building without needing to configure.

Now there is one thing I haven't added yet - parallel building. It should be as simple as adding separate threads when building files (right now it's a for loop). I know that's something a lot of people will care about, but it's not there yet. It's also really intended to only work with Linux rn, but it could probably pretty easily be adjusted to work with Windows.

Lay your project out like the minimal example, adjust the project layout, and get building! The project itself is actually bootstrapped and built using whatever the latest release is, so it's its own example haha.

It's dead simple and obvious to the point I would claim that if your project can't work with this, your project is wrong and grossly over-complicated in its design, and you should rework the build system. C is simple, and so should the build system you use with it!

So yeah. Check it out when y'all get a chance

view more: next ›