r/cpp • • May 05 '18

CPY (Pre)Compiler: C++ without redundancy

Thumbnail
github.com
3 Upvotes

r/cpp • • Apr 24 '20

C++ Fork?

0 Upvotes

Let me start by simply saying that I am fairly new to C++ and this is the first time I am posting to this sub-Reddit. I hope I am not breaking any rules here.

I have a question:

Would it be possible for C++ to be forked into a newer more modern version like the way Python went from version 2.x to 3.x? Maybe clean-up the language a bit, remove some redundant features etc.


r/cpp • • Mar 22 '18

Vote for best concepts terse syntax

Thumbnail
doodle.com
3 Upvotes

r/cpp • • Jun 06 '22

Clang for Windows

3 Upvotes

Is Clang still the optimal compiler for Windows? And if so then why is that the other windows compilers aren't as good?


r/cpp • • Feb 19 '25

Cpp discussed as a Rust replacement for Linux Kernel

192 Upvotes

I have a few issues with Rust in the kernel:

  1. It seems to be held to a *completely* different and much lower standard than the C code as far as stability. For C code we typically require that it can compile with a 10-year-old version of gcc, but from what I have seen there have been cases where Rust level code required not the latest bleeding edge compiler, not even a release version.

2. Does Rust even support all the targets for Linux?

3. I still feel that we should consider whether it would make sense to compile the *entire* kernel with a C++ compiler. I know there is a huge amount of hatred against C++, and I agree with a lot of it – *but* I feel that the last few C++ releases (C++14 at a minimum to be specific, with C++17 a strong want) actually resolved what I personally consider to have been the worst problems.

As far as I understand, Rust-style memory safety is being worked on for C++; I don't know if that will require changes to the core language or if it is implementable in library code.

David Howells did a patch set in 2018 (I believe) to clean up the C code in the kernel so it could be compiled with either C or C++; the patchset wasn't particularly big and mostly mechanical in nature, something that would be impossible with Rust. Even without moving away from the common subset of C and C++ we would immediately gain things like type safe linkage.

Once again, let me emphasize that I do *not* suggest that the kernel code should use STL, RTTI, virtual functions, closures, or C++ exceptions. However, there are a *lot* of things that we do with really ugly macro code and GNU C extensions today that would be much cleaner – and safer – to implement as templates. I know ... I wrote a lot of it :)

One particular thing that we could do with C++ would be to enforce user pointer safety.

Kernel dev discussion. They are thinking about ditching Rust in favor of C++ (rightfully so IMO)

https://lore.kernel.org/rust-for-linux/[email protected]/

We should endorse this, C++ in kernel would greatly benefit the language and community


r/cpp • • Apr 24 '24

C isn’t a Hangover; Rust isn’t a Hangover Cure

Thumbnail
medium.com
0 Upvotes

r/cpp • • Apr 10 '25

One of the worst interview questions I recently had is actually interesting in a way that was probably not intended.

47 Upvotes

Question is how long will the following program run:

int main()
{
    std::uint64_t num = -1;
    for (std::uint64_t i = 0; i< num;++i) {
    }
}

I dislike that question for multiple reasons:

  1. It tests knowledge that is rarely useful in day to day work(in particular that -1 is converted to max value of uint64) so loop will run "forever"

  2. In code review I would obviously complain about this code and demand !1!!1!!!1! 🙂 a spammy numeric_limits max that is more readable so this is not even that useful even if you are in domain where you are commonly hacking with max/min values of integer types.

What is interesting that answer depends on the optimization level. With optimization turned on compilers figure out that loop does nothing so they remove it completely.

P.S. you might say that was the original intent of the question, but I doubt it, I was actually asked this question by recruiter in initial screening, not an developer, so I doubt they were planning on going into discussions about optimization levels.

EDIT: many comments have issue with forever classification. Technically it does not run forever in unoptimized build, but it runs hundreds of years which for me is ≈ forever.


r/cpp • • Feb 27 '23

C vs “C with Classes” vs “modern C++”

10 Upvotes

i regularly come into this sub and hear that C and (modern) C++ fit different use cases and are valuable in their own respective rights.

simultaneously, this sub also suggests that modern C++ is better than C with classes.

This would all be fine and good, except that we also all agree that C with classes is better than C.

So, my question is this: huh?


r/cpp • • Jun 03 '25

Why C++ Still Deserves Your Heart as a New Developer – Despite All the Scars

Thumbnail
linkedin.com
0 Upvotes

r/cpp • • Dec 12 '21

is fmtlib going to be under standard in C++23?

2 Upvotes

I've been hearing some rumors that fmtlib might go under std since C++23 (what are your thoughts?). if so how would it differentiate between using one over the other. std::cout (taking operator<<), does it make sense to overload operator<< to some extent for std::print?


r/cpp • • Mar 11 '19

#include source "file.cpp", why not?

2 Upvotes

What if together with #include "file.cpp" the language would have something like #include source "file.cpp" ?

#include source "file.cpp"

Includes the file as a separate compilation unit rather than just inserting it in place as in case of existing #include.

Having such #include we may include libraries as simple as this:

 #include source "png.c"

 // where png.c file is just a list of all files from libpng:
 #include source "pngerror.c"   
 #include source "pngpriv.c"   
 #include source "pnggamma.c"   
 ...

This simple feature may eliminate the need of make, cmake, and pretty much all others from the zoo of makes. #include source and exiting C/C++ preprocessor should be enough in 90% of make cases.

Yet I think #include source can be used as a modules alternative.

Yet it is backward compatible - pretty much any exiting C/C++ library can be included that way in final executable without modification of library sources.


r/cpp • • Nov 10 '23

Advice for continue studies in C++

2 Upvotes

I have 9 years of experience in tech area, most of them as a manager, but I started my career as frontend developer. Nowadays I’m working as Technical Program Manager. Yes, I entered the Computer Programming college course with 9 years of experience, because I didn’t had the chance to do it immediately after the high school, I had to work to pay the bills, make money and after all that start the college.

I always considered extremely important have a strong foundation in programming and I like to program, besides I don't code anymore at work. I chose my course because it was based on C++ and I wanted to challenge myself. I had to confess it was a sour experience but I can say that I liked C++ overall and I was write I grew so much accessing this knowledge. Now I'm finishing the college and I’m afraid my contact and experience with C++ end with the course.

When I realized that I contacted a friend who is a experienced programmer and knows a lot about C++ and I asked him about what exists beyond the didactic field in C++. After a long talk I fell I have more questions now than before:

  1. It’s almost impossible cover every application field for C++, but which one I pick to start? Compilers and Interpreters, games, embedded systems… I just don’t know

  2. In some time of the talk he suggested me to start learning rust. I would say that this suggestion was like a cold bath, my first thought is: Do I need one more programming language now? I don’t know, looks like that people who are learning everything and know nothing. Does worth insist in C++?

  3. I considered get a job to continue programming in C++, but I don’t know if worth it. I look for some positions, besides that I don't know if anyone will give me a job with my experience being in other programming sector, mainly in the weird times we are living in terms of jobs.

I’m suffering a classic case of analysis paralysis and I hope you guys could give me some light on it.


r/cpp • • Jul 08 '19

C++ vs. Python

2 Upvotes

Although I have a bit of experience in both, I'm still having a hard time contemplating which of the two I should be aiming for mastery. Python is very beginner friendly, with a lot of resources and libraries. On the other hand, C++ is known for being a powerful language, while being complex and with a not so small learning curve. I wanted to focus more on robotics and you know, the cool stuff. But wait there's more...... Rasberry pi (python) or Arduino (c++). I'm just a naive 17 year old in my freshmen year of college, and am taking Electronics Engineering. Please enlighten me with your opinions. 😅


r/cpp • • Dec 31 '13

Build Qt/C++ applications for real-time collaboration

2 Upvotes

Hello,

We've just opened the public beta for the Zeecrowd plateform. From the post on qt-project.org

The idea: create your own private secure network “a crowd”, install applications from the store, invite people to join your “crowd” and everyone can connect and use the crowd’s applications.

For application developpers we wanted to ensure that it was as simple to transform existing single-user applications into multi-user applications as to develop collaborative applications from scratch.

The platform's API provides an environment where developers do not worry about the complexity of the collaborative experience (managing user connections, messaging, notifications, resource sharing in the cloud, managing the deployment and distribution of applications, user group management, security issues, …). More here

For those interested, feel free to give us your feedback. We highly appreciate it. Thank you.


r/cpp • • Apr 27 '14

Writing a bar graph widget in Qt

Thumbnail meetingcpp.com
2 Upvotes

r/cpp • • Jan 09 '18

bedst build system to c++?

0 Upvotes

Which build system is the best to use for c ++ code and its dependencies (SDL in my case)?


r/cpp • • Feb 06 '21

Inconsistent for-loop syntax?

2 Upvotes

Does anyone know of a technical reason why I can use this for-loop syntax:

for (std::size_t i{}; i < string.size(); ++i) {...}

as well as this:

for (std::size_t i{}; char ch : string) {...}

but this is invalid:

for (std::size_t i{}; char ch : string; ++i) {...}

In other words, why am I able to add an init-statement to a ranged for loop but not an end-of-iteration expression? To me this seems inconsistent.


r/cpp • • Apr 03 '18

Newer C++ features can create a lot of system yak shaving

Thumbnail rachelbythebay.com
2 Upvotes

r/cpp • • Sep 06 '20

inline namespace bug in msvc

2 Upvotes

I went to report this using the IDE and it asked me to "log in" which I tried but Microsoft's browser widget broke my password manager so I said to login with GitHub and when I pressed that button another browser window popped up asking me to log in to GitHub but at the top it said "GitHub does not support this browser (lol)" so I gave up and I am posting this code snippet here:

This fails to compile in latest msvc:

namespace boost {
namespace json {

inline namespace standalone {
namespace detail {
struct V{};
} // detail
} // standalone

namespace detail {
struct T{};
} // detail
struct U : detail::T{};

} // json
} // boost

See: https://godbolt.org/z/qbPesG

It compiles everywhere else


r/cpp • • May 31 '22

A Garbage-Collected Heap in C++, Shaped Like Typed Python

Thumbnail oilshell.org
4 Upvotes

r/cpp • • Jan 08 '23

What are the state of C++ audio, 2D graphics and contract in C++23/26?

0 Upvotes

r/cpp • • Oct 10 '23

Beginner's guide to raw C++ pointers especially for audio programming: this is the bit that most audio programmers new to C++ get wrong or misuse. This resource is meant to help them avoid common pitfalls. Includes the explanation of float**, void*, and const float* const* const 😉

Thumbnail
youtu.be
4 Upvotes

r/cpp • • Dec 12 '24

What′s up with Telegram messenger: dozen errors in C++ code detected

Thumbnail
pvs-studio.com
0 Upvotes

r/cpp • • Mar 14 '21

CMake IS a Build System

Thumbnail alexreinking.com
7 Upvotes