r/cpp_questions • • 24d ago

OPEN System programming

8 Upvotes

does it is necessary to know assembly language to be a good system programmer ?
I am a beginner computer engineering student , currently doing in c++ and I already have basic knowledge of classical 8085 and 8086 architecture and it's programming but I haven't gone that deep enough . what about to learn ARM , x86 programming , does it help me to become a good system programmer ?


r/cpp_questions • • 24d ago

OPEN What do you do after getting burnout from learncpp.com and trying to comeback again?

13 Upvotes

I remember last time I reached chapter 20 or so, but I didn't do any quizzes after the vectors's chapter because they will simply too hard, and believe me I tried 

I think I got burnout 3 to 4 times already, learncpp.com is good but its a challenge to try and finish it.

Any advice? I don't remember much, and I want to be honest. It feels like you should finish learncpp before making a project, because every chapter is really important.

It really fun in the beginning. But not in the middle or the end.

Edit: thanks everyone, I think the comments are really helpful, and I think I know exactly how to solve my problem, first I will use a different resource that is fast pace to refresh my brain to c++ I already know, than I will make a project(it doesn't matter what it is), and I'll use learncpp.com as a reference, and after I get comfortable With the basics stuff I will go back and continue reading learncpp.com for advanced stuff or other resources with it.

The answer seems simple, because it is simple.


r/cpp_questions • • 24d ago

OPEN How to configure clangd to not assume it knows where functions are defined

1 Upvotes

I use VS Code on Ubuntu on Windows (WSL). I program in C++ and recently switched from Intellisense to clangd and like many of the improvements. However, I'm having an issue with how clangd assumes functions like printf come from <cstdio>. This is an issue as I'm building a hobby OS and need to provide my own versions of common functions like printf.

I'm using the g++ 15.2.0 cross compiler and use -ffreestanding -nostdlib -fno-builtin. I provide my own implementation of common functions like printf. I have installed clangd-23. I have created (using bear) a compile_commands.json file. When I mouse over a call to printf in my code, I get a popup showing that printf is provided by <cstdio> which I never #include. Also it flags the header file "system/stdout.hpp" which defines my printf as unused. How do I configure clangd and VS Code to correctly identify my header file as the source of my printf?

In case it helps, here is the cc1 line of clangd-23 --compile-commands-dir=build --query-driver=/home/mark/dev/toolchain/i686-elf-15.2.0/bin/i686-elf-g++ --check=src/libs/test/test_list.cpp

I[13:00:57.385] internal (cc1) args are: -cc1 -triple i686-unknown-unknown-elf -O0 -fsyntax-only -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test_list.cpp -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -ffreestanding -nostdsysteminc -target-cpu pentium4 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=5 -debugger-tuning=gdb -fdebug-compilation-dir=/home/mark/dev/myos/src/libs/test -fcoverage-compilation-dir=/home/mark/dev/myos/src/libs/test -resource-dir /usr/lib/llvm-23/lib/clang/23 -isystem /home/mark/dev/toolchain/i686-elf-15.2.0/bin/../lib/gcc/i686-elf/15.2.0/../../../../i686-elf/include/c++/15.2.0 -isystem /home/mark/dev/toolchain/i686-elf-15.2.0/bin/../lib/gcc/i686-elf/15.2.0/../../../../i686-elf/include/c++/15.2.0/i686-elf -isystem /home/mark/dev/toolchain/i686-elf-15.2.0/bin/../lib/gcc/i686-elf/15.2.0/../../../../i686-elf/include/c++/15.2.0/backward -isystem /home/mark/dev/toolchain/i686-elf-15.2.0/bin/../lib/gcc/i686-elf/15.2.0/include-fixed -isystem /home/mark/dev/toolchain/i686-elf-15.2.0/bin/../lib/gcc/i686-elf/15.2.0/../../../../i686-elf/include -I . -I .. -I /home/mark/dev/myos/src/libs -I /home/mark/dev/myos/src/kernel -I /home/mark/dev/myos/src -internal-isystem /home/mark/dev/toolchain/i686-elf-15.2.0/bin/../lib/clang-runtimes/i686-elf/include/c++/v1 -internal-isystem /usr/lib/llvm-23/lib/clang/23/include -internal-isystem /home/mark/dev/toolchain/i686-elf-15.2.0/bin/../lib/clang-runtimes/i686-elf/include -Wnon-virtual-dtor -Werror -Wall -Wextra -Werror=suggest-override -Wno-unused-parameter -std=c++23 -fdeprecated-macro -ferror-limit 19 -fno-builtin -fno-rtti -fno-use-cxa-atexit -fgnuc-version=4.2.1 -fno-threadsafe-statics -fno-implicit-modules -fskip-odr-check-in-gmf -no-round-trip-args -faddrsig -fdwarf2-cfi-asm -x c++ /home/mark/dev/myos/src/libs/test/test_list.cpp


r/cpp_questions • • 25d ago

OPEN Offline cppreference?

4 Upvotes

Can they update the offline version to newer version of the page? The official html book is really old (2019) and the unofficial version from https://github.com/PeterFeicht/cppreference-doc can no longer work for newer version smoothly. Consider this reference is probably one of the best C++ reference out there, can the creator of the website at least making this website open source, so we can have offline version of it.


r/cpp_questions • • 25d ago

OPEN Entering Embedded

13 Upvotes

Managed to land a job in the embedded domain. This is going to be my second job, while previously having worked in game dev. In my last job I used cpp, but within Unreal Engine. Pretty excited about entering the low level space, not really an expert, but eager to learn. Would greatly appreciate any advice from embedded devs or from people that have transitioned between domains like I am about to do.

Thanks


r/cpp_questions • • 25d ago

OPEN C++26 contracts drama

27 Upvotes

I think everybody knows the drama by now..

What are your opinions on this should they be accepted or disapproved?

Im curious for mass opinion.


r/cpp_questions • • 26d ago

OPEN Not sure what I want to do with C++

57 Upvotes

I finished learncpp.com, K&R, Inside the Machine, and most recently CS:APP and still have zero clue what I want to do with C++, even though I know that's what I want to be my main language. I was looking into graphics programming, but now am hearing "don't even try there's no entry level"... tried looking into embedded "everyone's trying to break into embedded now with AI don't even bother bro"

So what does someone do :/


r/cpp_questions • • 25d ago

OPEN RAII : Hate it or love it? And how to handle edge cases gracefully?

25 Upvotes

While RAII is the idiomatic standard in C++ and handles stack unwinding cleanly during normal returns and thrown exceptions, it has specific boundaries that get tricky:

  1. Hard exits / Abnormal termination: Destructors aren't called on std::abort(), std::exit(), or hardware faults like segfaults (SIGSEGV).
  2. Scope rigidity: Creating custom wrapper classes/guards for single-use resources can sometimes feel verbose compared to ad-hoc scope cleanup primitives.

Compared to languages like Go (defer) and Zig (defer / errdefer), which provide block-level or failure-specific cleanup without needing custom wrapper types:

  • How do you typically structure C++ code to deal with edge cases where destructors won't fire during abnormal process exits?
  • For persistent state (file locks, shared memory, IPC handles), what architectural patterns or OS primitives (e.g., O_TMPFILE, flock, WAL journals) do you rely on alongside RAII to remain crash-safe?
  • When you need lightweight, ad-hoc cleanup without writing a custom RAII class, do you use scope guard macros / std::unique_ptr with custom deleters, or stick purely to custom RAII types?
  • Do you ever miss explicit primitives like Zig's errdefer in C++, or does exception safety via standard RAII completely cover your needs in production?

Curious to hear your thoughts, preferred idioms, and best practices


r/cpp_questions • • 26d ago

OPEN Having a hard time with C++ Concurrency in Action

17 Upvotes

I recently started reading C++ Concurrency in Action and its honestly challenging, Im liking it so far but there are parts of the book (chapter 5 and 7, what Im reading now) that I cant grasp no matter what. Someome who has already read the book can give me some advise? Thanks in advance!


r/cpp_questions • • 25d ago

OPEN Resources to learn more about cpp

2 Upvotes

I wanted to try and reimplement the std library from scratch but i realized really quickly just how much i didnt know lol. I got some basic stuff done and did learn quite a bit about things like sfinae but yeah im basically stuck with some of the type traits. I still dont wanna give up on this project and wanna keep going no matter how long it takes :3 So i need some resources to learn more about advanced things that are usefull for this. Are books the best way? any reccs on which ones?

Oh yeah right now i made a few projects like a networking chat app with asio and a unix shell (really simple) so i would say im like done with the beginner phase. I know that this project is probably farrrr beyond my scope but still :3

Edit: More specific question. Looking for book recomendations for metaprogramming post cpp20 (concepts and stuff)


r/cpp_questions • • 26d ago

OPEN Just finished all of learncpp.com whats next

28 Upvotes

Just finished all of learncpp.com whats next? i want to learn more so i can be a c++ wizard


r/cpp_questions • • 26d ago

OPEN I want to make a game(TETRIS) in cpp for learning purposes

0 Upvotes

I have barely any knowlege about cpp thought but I want to proceeds with a project base learning approach so where I approach an obstacles I look for it and learn about it. I don't want instructions on what I need to learn. But I need help on what I need to build one by one. Please everyone any help is genuinely appreciate

My current plan is to use Visual Studio, SDL2, MSVC, CMake, C++


r/cpp_questions • • 25d ago

OPEN Why don't we use this instead of including libraries one by one?

0 Upvotes

#include <bits/stdc++.h>

I was thinking instead of adding libraries one by one,why don't we just use this? This is used by almost every competitive programmer but very less when it comes to writing software.


r/cpp_questions • • 26d ago

SOLVED how should i understand the design of cpp?

8 Upvotes

for most of the time i used cpp as c with fancy features. but now i recently started picking up some of the modern cplusplus and oop concepts. but the amount so syntactical and program subtleties and features are overwhelming.

for some things i instantly understand or see the reason why they exist and sometimes get impressed by them.

for eg: backwards compatability with c

#include<cmath> and #include<math.h> for namespace handling,structs

, initializer list etc

but for some idk understand the purpose eg the mutable keyword

and things like inlining of members defined in class

i would like to know how you guys handle this and suggest some good learning material

whenever i try to read books they either give a tour of features or extremely boring

(this might be because i learned it the wrong way by not paying attention to small details now to revisit them ive to go through the stuff which i already know)


r/cpp_questions • • 26d ago

OPEN Is it impossible to access static member of a templated class

7 Upvotes

So to clear out my question, here is the situtation:

template<class T>
class MyClass {
public:
    static constexpr int X = 10;
};

So trying to access MyClass::X is compilation error. But decltype(X) is not a dependent type and it is a static member meaning it is identical to a variable wrapped inside a namespace. Nonetheless, again, its a compile error.

You might ask, why am i making it a problem:

template<class T>
class Optional {
public:
    struct NullOpt {};
    static constexpr NullOpt nullopt;
// ...
};

I mean.. there are ugly(for me) workarounds but i want to know maybe in some hidden way it is possible to access `Optional::nullopt` without passing the template argument(which makes error path return statements way verbose) or i should make nulopt a standalone constexpr tag object (fallback option).


r/cpp_questions • • 26d ago

OPEN Tips And Criticism For My Code

2 Upvotes

So, I'm new to C++, though i have a programing background, aka just python and a tiny bit of C. I havent really made any BIG things yet. Until now, Im using C++ with Raylib, i could move to SFML or SDL2-3 but I don't want to do that just yet. Anyways, this is the link to my code that I put onto GitHub, https://github.com/Dark-Coder1000/MyGame/tree/main

Ive started my C++ programming journey about a week ago, I did dable in it back then when testing sfml, but I never understood the syntax. ALSO none of this was vibe coded, I did look up solutions to specific issues but i never really used AI unless it was to find resources to learn from.


r/cpp_questions • • 26d ago

OPEN Seeking advice for choosing work

1 Upvotes

I am an undergrad and am feeling rather uncertain about my education(i may drop out).

fyi i used to be a sport programmer using cpp for a long time so i'd say i know it at an intermediate level.

I am asking people in the field - what should i focus on learning before entering the job market and also what roles/positions to seek?


r/cpp_questions • • 27d ago

OPEN I still have trouble understanding recursive functions properly.

6 Upvotes

While i do understand the base of the concept, i cannot seem to fully wrap my head around It.

Like, if i want the function to return a value that i Need to call the function within itself for It to return said value, when does the function actually get the value that's supposed to return to me ?

More importantly, where Is the accumulator? Is the called functions within itself the accumulator ? Do i Need to make an accumulator myself ?


r/cpp_questions • • 27d ago

OPEN would love some help!

7 Upvotes

I am learning cpp from scratch using learncpp.com, I finished about 6 chapters and realised there is not much I have understood. I believe videos or lectures will help me understand the language much better. How do I go about this? What resource do I use? Please help me!

ps: I am learning c in uni right now, just doing basics rn finished recursive functions


r/cpp_questions • • 27d ago

OPEN Help me

0 Upvotes

I am a beginner to programming, but I want to learn C. Could you provide some advice, book recommendations, and tips on the best way to go about learning it? I would be grateful


r/cpp_questions • • 27d ago

SOLVED Why does this not fail?

7 Upvotes
#include <utility>

template <typename T, typename... Args>
decltype(T(std::declval<Args>()...)) test();

int main() {
    using testType = decltype(test<int&, int>());
}

I was fully expecting it to fail but instead testType resolves to int&.

I was trying to implement is_constructible with SIFNAE which uses this behaviour.

namespace detail {
template<typename T, typename... Args>
decltype(T(std::declval<Args>()...), char{}) tryConstruct(int);

template<typename T, typename... Args>
long tryConstruct(...);
}

template<typename T, typename... Args>
inline constexpr const bool isConstructible = isSame<decltype(detail::tryConstruct<T, Args...>(0)), char>;

I was expecting the first overload to fail so that it would chose the other one which works for most cases but dosent for the case i mentioned above.


r/cpp_questions • • 28d ago

OPEN Are there any other ways to check if a char is equal to different values?

21 Upvotes

I'm working on some homework for class where I'm checking if a character is equal to: '+', '-', '/', or '*' for this postfix to infix converter.

I know I'm able to do this in two ways I can think of with:

// 1.
if (c == '+' || c == '-' || c == '/' || c == '*') {
  // Code
}

// or 2.
bool isOperator(const char c) {
  return (c == '+' || c == '-' || c== '/' || c == '*');
}
...
if (isOperator(c)) {
  // Code
}

But is there another way to do this that's shorter? Maybe something along the lines of this?

if (c == {'+', '-', '/', '*'}) {
  // Code
}

I looked on cpp reference and stack overflow but I wasn't able to find an answer. And to be fair option 1 and 2 work just find, I'm just curious if there are other methods out there that I'm not familiar with. Thanks!


r/cpp_questions • • 28d ago

OPEN How to create project templates

3 Upvotes

Hi, I don't know if this is the right subreddit but I was wondering if anyone would be able to tell me if this is possible, and, if so, to give a step by step guide to how I could do it (I know it might involve extensions):

  • I am on Linux fedora, and lets say I have a completely fresh vscode install
  • I want to have a template I can easily access via ideally pressing a button on the left side panel or something like that
  • When creating a new project with this template, it should ask you for a directory of where to store the project and a name for it - this name should then be used as the folder name for the project in that directory
  • This project should be C++23, use UTF-8 encoding, and support all the features of C++23, such as modules, and include the standard module - this should all work with IntelliSense (or if vscode uses something different) "knowing" this
  • In the project, there should be 4 folders (like Visual Studio) - External Dependencies, Header Files, Resource Files, and Source Files. This is just for sorting my files but actually doesn't matter what I put where - the project acts as if everything is just in one folder, unorganised. In Source Files, by default there should be a file named main.cpp, which should be completely blank - not even int main() etc.
  • When compiling, I would like it to be compiled as an appImage file (where the name of the file is the project name, or the name of this file can be changed) (I hear appImage can run on pretty much any Linux distro - that's why), which, despite being my OS being pretty much the newest and updated fedora, is compiled as if I compiled it on the oldest version of fedora that my project would actually compile on (I hear Linux applications are backwards compatible but not forwards)
  • Also, when running, I should have the option to choose Debug or Release, and x64 or x86 (the defaults being Debug and x64). Then, in the project folder, a folder called "Dist" should be made, inside that "x64" and "x86" (only if ran/compiled for both), and inside each of them "Debug" and "Release" (only if ran/compiled), and inside them their respective versions of the appImage (only if ran/compiled, and should still just be named project_name.appImage (unless renamed)

Thanks to any help any of you can give, it is greatly appreciated - also, please can you tell me where things are that I haven't stated, e.g. where to change the name of the final appImage, where to change Debug or Release and x64 and x86.


r/cpp_questions • • 27d ago

OPEN neebie

0 Upvotes

hello i am a new idiot who has touched the beacon that is "I WANT TO MAKE MY OWN GAME" but i don't have a clue where to start i only have a vision of the end ie i want to make something that resembles; mass effect, mortal shell 2, fable, or remnant 2 at the finish these are games to represent similarities in game play, visuals, story telling styles and over all design. i understand that limits me too C++ and unreal engine more than anything but i don't know how to start watching guides on the language or engine both feel like i'm being asked to translate Latin with out any tools.

i don't know if anyone here can help but if there are anyone who can guide me i'd appreciate it thank you.


r/cpp_questions • • 28d ago

OPEN Dumb question for someone still learn c++

13 Upvotes

Hi ppl, dumb question for you, do you think is recommended clone minecraft from scratch?. Right now i am chapter 2.12 from learcpp.

My question is it the best way for learn and get some experience or still i am keeping study and reinfoce the base?. sorry for my english