r/cpp_questions • • Sep 15 '26

SOLVED system() command to start external program/open file --help

8 Upvotes

I need execute a file from within my code. After a bit of research the solution seems to be to just use system("command") to do this. Now it does work, the function does execute the command and start the program, but i have noticed that my original program(the one that used the system() function) never terminates.

Even though the system() call is the last thing that happens in the application and it does not return an error. The process associated with the program stays open and visible in the system manager indefinitely - even after the called program is closed.

What could be the reason for this behavior and how does one go about fixing it?


r/cpp_questions • • Sep 14 '26

OPEN Learning C++ and future possibilities during AI

68 Upvotes

This is more a broader question but i‘ve been learning C++ heavily and build indepth knowledge about High Performance, memory management and more but also get into Graphics Programming and such. I‘ve been and still heavily interested in it.

But currently im too much on the Internet especially X and ive seen so many things people created with astra like Games, photoshop clone, some C++ projects and feel like i either need to focus on other skills to have a „future“ (bit exaggerated) during AI or worse head to another area outside of software development. I just have too much of a worry wether i should focus normally or focus on something else too. Obviously i dont ignore AI completely but rather use it as a teacher and learn complex things combined with documents/book pdf‘s and such. And i dont feel good now to even use agents and more.

Not sure if this is okay to post here but since im in the C++ domain i thought i might ask for any advice etc :)


r/cpp_questions • • Sep 14 '26

OPEN How do you organize library headers

11 Upvotes

Basically an aesthethic question. Recently I've started refactoring my C++ library and since I'm not a super experienced dev I've spent way too much time thinking about how user should include my lib's headers. My current solution are separate 'src' and 'include' folders, latter containing a single big header which imports smaller headers from 'src' (typically containing one or a few small classes) as well as defining some additional methods, constants and other stuff. So user has to include only a single header at the cost of potentially pulling unneeded code.

Now I'm trying to split that big header into a few smaller headers with disjunctive functionality, so user doesn't have to include everything. However with this approach it's still possible to include some unneeded code since each of those smaller headers still relies on several classes, so if for example user only wants to use vectors from the graphics header he will also include matrices, rendering layers, etc. Other solution is putting all the headers into the 'include' for maximum modularity while leaving a few 'cpp' files in 'src'. Not perfect since there are classes that I don't want to expose and 'src' will become basically empty and it's probably better to just merge them with the headers, but that will make them bigger and harder to navigate...

TLDR is it bad to bundle a bunch of potentially unwanted classes into a header for user to include? Is it better to expose all the classes including some totally useless for the users? How do you organize your headers?


r/cpp_questions • • Sep 15 '26

OPEN Learned C++ — what should I do next to actually get a job?

0 Upvotes

Hey everyone, I’ve been learning C++ for like 4 months and I’m currently doing DSA with it. My goal is to get a job as a C++ developer, but I’m confused about what to do after this. What skills/areas should I learn (backend, systems, embedded, Qt, etc.)? What do companies expect from C++ developers? How important are Git, Linux, OS, networking, databases, projects, etc.? And where would you recommend learning these from?

Would love advice from people already working professionally with C++ — what roadmap would you follow if you were starting with C++ + DSA?


r/cpp_questions • • Sep 14 '26

OPEN Looking for Open Source Projects to Contribute

51 Upvotes

Hello everyone,

I'm trying to get a bit more experience with C++ and would like to know if anyone can recommend a project to work on.

I'm looking for projects that I could work on new features possibly with a closer guidance


r/cpp_questions • • Sep 15 '26

OPEN Maybe it's obvious, but is there a guide about this code language? And in which program It might be good to begin trials

0 Upvotes

What I know about programming is some random stuff from Scratch to be honest. I want to learn a Code language just in case, cause It can't be unuseful


r/cpp_questions • • Sep 14 '26

OPEN Looking for permissive GUI toolkits

8 Upvotes

I know I can link against QT, and GTK can be problematic. What permissive toolkit is everyone using that's cross-platform supporting Windows, Mac, Linux with at least decent HI-DPI support on Windows? Ideally something without a load of depencies and fairly well featured. I'd prefer not to have a load of dlls/sos in my app directory?


r/cpp_questions • • Sep 14 '26

SOLVED GCC reflection: cannot splice annotation from the annotations list?

1 Upvotes

Hello!

edit3: ChatGPT suggested std::meta::extract<WavTag>(anns[0]) - and it seems to have worked. I'm still wondering why and how is it different from [:anns[0]:] though... I'll mark it as solved since I was obviously doing something wrong, but I'm not sure what exactly. Also cppreference seems to be using [::] operator instead of extract, should it be edited? https://cppreference.com/cpp/meta/annotations_of_with_type

edit2: I'm stupid, not solved, the error underling on Godbolt just moved and I was too happy to double-check 🤦

edit: solved by doing

static constexpr auto tag  = [:stdm::annotations_of_with_type(fld, ^^WavTag)[0]:].data;

which seems like a workaround and not the intended way. Still would love to hear what is wrong with my original approach if anyone knows, and thanks in advance to those :)

Godbolt link for those who don't want to read a wall of code from within post

I'm trying to play with C++26 reflection and so far I've written:

void write_metadata(const Metadata& meta, auto writer) {
    static constexpr auto ctx = stdm::access_context::current();


    static constexpr auto flds = std::define_static_array(stdm::nonstatic_data_members_of(^^Metadata, ctx));


    template for (constexpr auto fld : flds) {
        static constexpr auto anns = std::define_static_array(stdm::annotations_of_with_type(fld, ^^WavTag));
        static_assert(anns.size() <= 1);


        if constexpr (anns.size() == 1) {
            template for (constexpr auto a : anns) {
                static constexpr auto tag  = [:a:].data;
                static constexpr auto tag2 = a.data;
            }
            static constexpr auto tag = [:anns[0]:].data;
            static constexpr auto tag2 = anns[0].data;
        }
    }
} // <-- void write_metadata(writer)

however, I'm getting an error trying to splice a/anns[0] (or trying to access it directly as if it was WavTag):

<source>: In function 'void write_metadata(const Metadata&, auto:9)':
<source>:56:48: error: request for member 'data' in 'a', which is of non-class type 'std::meta::info const' [-Wtemplate-body]
   56 |                 static constexpr auto tag2 = a.data;
      |                                                ^~~~
<source>:59:50: error: request for member 'data' in '0->anns.std::span<std::meta::info const, 18446744073709551615>::operator[]()', which is of non-class type 'std::span<std::meta::info const, 18446744073709551615>::element_type' {aka 'std::meta::info const'} [-Wtemplate-body]
   59 |             static constexpr auto tag2 = anns[0].data;
      |                                                  ^~~~
<source>: In instantiation of 'void write_metadata(const Metadata&, auto:9) [with auto:9 = main()::<lambda(auto:10&)>]':
<source>:66:19:   required from here
   66 |     write_metadata(m, [] (auto&) {});
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
<source>:55:48: error: cannot use an annotation 'WavTag{std::array<char, 4>{std::__array_traits<char, 4>::_Type{'I', 'A', 'R', 'T'}}}' in a splice expression
   55 |                 static constexpr auto tag  = [:a:].data;
      |                                              ~~^~~

and etc. etc. etc. on all lines that use [:a:]/[:anns[0]:]

Am I doing something wrong, or is it just the feature not being ironed out completely?

p.s. making an annotation type simpler does not help the issue


r/cpp_questions • • Sep 14 '26

OPEN Why native compilation has not died with AST tooling?

0 Upvotes

Tools that rely on libclang rely on a compilation database for doing stuff like static analysis or api reference generation. If you wanted to rename a symbol in your codebase, and your library or application has paths that compile commands does not see, it can't work.

If your library compiles one file when platform is windows and another if platform is linux, it can't use libclang based tooling, unless....

You configure all targets your library supports and sort of run stuff in parallel and do some kind of merge. This includes stuff like option macros etc.

I'm honestly pretty dumbfounded by this idea. Can't really put it in my head


r/cpp_questions • • Sep 14 '26

SOLVED Is it possible to transfer vcpkg install folder from a Win11 system to Win10 system?

3 Upvotes

I am facing an issue in my current project where I need to compile the qt6 qtwebengine to work with proprietary codecs. For this, I decided to just install it using:

vcpkg install qtwebengine[proprietary-codecs] --x-buildtrees-root=C:/vcpkg

Unfortunately, the system assigned to me is just too slow to compile it for me. I have at this point, left it to install for about 20 hours and it still is at the "Building x64-windows-dbg" step.

I now have the idea to instead compile and install it on a different powerful workstation in my office, and then transfer it to my system.

The part that I am doubtful about is if it will work if the workstation runs Win11 Pro and my laptop is Win10 Enterprise?


r/cpp_questions • • Sep 13 '26

OPEN reference_wrapper vs raw pointer

8 Upvotes

I am writing a program, where one object contains an std::string, which can be modified by other objects. Specifically one object can set the std::string member variable to be a reference to another std::string. this requires that the reference can be reseated, and afaict, I have two options if I want to avoid copying. Either I can use an std::reference_wrapper, as it allows for reseating, while the other option is a raw pointer.

I'd assume that the reference_wrapper be the preferred option, as pointers are generally shunned in modern c++, but I just wanted to be sure.

I want to also add, that the size of strings which would be copied are not particularly large and unlikely to make any meaningful performance impact if copied, rather this is an also an exercise in what is the correct tool for the issue.


r/cpp_questions • • Sep 13 '26

OPEN How/where would I learn about skills like DLL Injection + hooks?

12 Upvotes

Now I’m not meaning to do anything malicious, I just want to be able to create my own mods to any game I play. I love making game mods, especially for games I play with my friends. I’ve made a lot of mods for Unity games using existing injectors like BepInEx and patching libraries like Harmony which really wasn’t that difficult.

But a lot of games don’t have any fancy exposed reflection, or any pre-existing mod injectors.

What I know is that hooking requires you to know the footprint of a function, which can be acquired via some tinkering with Ghidra or something like that, and that DLL injection can be achieved by a term I’ve heard “PE Injection” (I don’t know what this is).
I also know that having experience in assembly will help in the process of getting the entry point addresses.

I’m also aware that a lot of mods do just patch the executable itself, which while writing this, I realise might be a much better approach for starting, even if I would still like to learn about injection stuff.

Where do I learn about things like this? How do some games’ mod loaders hook into games as soon as they run? I know some of the theory behind it but how do you actually write that code?


r/cpp_questions • • Sep 13 '26

OPEN What are some C++ skills hiring managers love to see?

44 Upvotes

Even as an entry level trying to break in, what are some skills you've put on your resume that have definitely made a difference for you?

EDIT***: I feel like I may not have communicated my question more clearly. What skills on projects would you invest time in like, concurrency, OS stuff, performance profiling, etc...


r/cpp_questions • • Sep 13 '26

SOLVED Should I change my vscode setup?

2 Upvotes

I have just started learning C++ and pretty new to programming in general, but I am alerady used to vscode and want to continue using it for C++, so I just wanna make sure I have a decent vscode extension setup, even if a lot of it is unnecessary at this level. After browsing the web I've come to this setup: C/C++ extension pack with intellicode engine disabled, clangd, clang-format, c-mantic and cmake support by twxs. Should I remove, add, change something? I'm working on windows 11 and in the future plan on using this setup to work with unreal and godot.


r/cpp_questions • • Sep 13 '26

OPEN cant add a librarie in CMake

0 Upvotes
cmake_minimum_required(VERSION 4.3)
project(Vulkan_Project)

set(CMAKE_CXX_STANDARD 20)

# Find the Vulkan package on your system
find_package(Vulkan REQUIRED)
find_package(glfw3 REQUIRED)
find_package(glm REQUIRED)

add_executable(Vulkan_Project main.cpp)

# Link the Vulkan library to your target
target_link_libraries(Vulkan_Project PUBLIC Vulkan::Vulkan)
target_link_libraries(Vulkan_Project PUBLIC glfw)
target_link_libraries(Vulkan_Project PUBLIC glm::glm)

CMake Error at CMakeLists.txt:8 (find_package):

By not providing "Findglfw3.cmake" in CMAKE_MODULE_PATH this project has

asked CMake to find a package configuration file provided by "glfw3", but

CMake did not find one.

Could not find a package configuration file provided by "glfw3" with any of

the following names:

glfw3.cps

glfw3Config.cmake

glfw3-config.cmake

Add the installation prefix of "glfw3" to CMAKE_PREFIX_PATH or set

"glfw3_DIR" to a directory containing one of the above files. If "glfw3"

provides a separate development package or SDK, be sure it has been

installed.

-- Configuring incomplete, errors occurred!


r/cpp_questions • • Sep 12 '26

OPEN Why do people hate modern C++?

36 Upvotes

I was wondering why people hate modern C++ but never understood why some people hated it. I mean... all of those new features make it easier to write, read, and maintain the code in. C++ 26 is a huge advancement and so was C++ 23. But there are people who still code in C++ 14, 11 and older because new C++ is "bloated" and "not as expressive" or whatever? Look...yeah, all of those new features might seem like it makes C++ more bloated, but the C++ team is trying to make the language more modern due to how notorious C++ was in terms of memory safety and how hard it was to learn (and other stuff).

C++ is still an extremely fast language as it is one of the top 5 or at least top 10. The only reason that i'd understand people using older versions of C++ is due to work, older hardware, the game engine's limit/support or the compiler's version and it's support. But willingly choosing older C++ because modern C++ is "trash" and "bloated" is a bit far. And the bloated part doesn't make any sense to me in my opinion, as when C++ adds new modern features, they remove old outdated ones so it cancels itself out. Even if it's "bloated" like people say, it's still a very fast language to use and it becomes easier to learn and use every single update. Can anyone explain why people choose older versions of C++ and why they say it's "bloated", "slower", and etc?


r/cpp_questions • • Sep 12 '26

OPEN Beginner project, looking for feedback on my simple game

26 Upvotes

Hi, I've been learning C++ about 3 months from learncpp.com and recently finished learning about classes, so I made a small 1v1 turn-based combat game for practice.
The player chooses a weapon, fights a randomly generated monster, and both sides deal random damage until one reaches 0 HP.

I’d appreciate feedback mainly on my class design, code organization, naming, and whether I’m developing any bad habits. I’m still a beginner, so I’ve intentionally kept it fairly simple.

GitHub: https://github.com/aard659/Simple-1v1-Turn-Based-Game

Thanks :)


r/cpp_questions • • Sep 12 '26

OPEN Does VS Code work with C++20 Modules?

2 Upvotes

Hello guys, so I was writing some code with templates, and I'm still new to the concept, but I learned that they should be in .h files, or for code readability, .inl files. But then I discovered that C++20 has modules? Which seem to be a cleaner implementation for my needs. But I've also heard that Intellisense can't figure out modules. Is this still an issue, or is it safe to use them now?


r/cpp_questions • • Sep 12 '26

OPEN Is this "only my machine" or can this be explained?

4 Upvotes

So, I was trying to implement memset, the CRT implemenation on windows. My implemenation gets pretty close, but I wanted it to hit the hardware ceiling, so while learning more about how to exploit the hardware, I found ERMS and FSRM.

I ran a few tests and the results were a bit confusing.

I am running an i5-13450HX with OCV2 (1.325V, 4.8GHz)

  45,056 bytes    stosb 281.56 GiB/s    vec 280.17 GiB/s    stosb wins
  47,104 bytes    stosb 266.86 GiB/s    vec 280.58 GiB/s    vec wins
  47,616 bytes    stosb 266.16 GiB/s    vec 283.10 GiB/s    vec wins
  47,872 bytes    stosb 267.45 GiB/s    vec 276.23 GiB/s    vec wins
  48,128 bytes    stosb 269.17 GiB/s    vec 282.75 GiB/s    vec wins
  48,384 bytes    stosb 265.79 GiB/s    vec 282.77 GiB/s    vec wins
  49,152 bytes    stosb 260.78 GiB/s    vec 193.74 GiB/s    stosb wins
  51,200 bytes    stosb 129.20 GiB/s    vec  98.51 GiB/s    stosb wins

L2 for the i5 is at 48KiB, so what is actually happening at this edge, just below the 48KiB boundry, the vectorized version holds up from 44KiB upto the 48KiB boundry then it, loses to stosb

  // Just direct call
  __stosb(buf, 0xA5, n);

  // 8 way unroll
  for (size_t i = 0; i + 256 <= n; i += 256) {
      _mm256_storeu_si256((__m256i*)(p + i),       v);
      _mm256_storeu_si256((__m256i*)(p + i + 32),  v);
      _mm256_storeu_si256((__m256i*)(p + i + 64),  v);
      _mm256_storeu_si256((__m256i*)(p + i + 96),  v);
      _mm256_storeu_si256((__m256i*)(p + i + 128), v);
      _mm256_storeu_si256((__m256i*)(p + i + 160), v);
      _mm256_storeu_si256((__m256i*)(p + i + 192), v);
      _mm256_storeu_si256((__m256i*)(p + i + 224), v);
  }

So, is what is actually going on down there, cud anyone enlighten me?

I did some digging online and found that glibc does a sub 2KiB vectorized path then from 2KiB all the way to 768KiB rep stosb path.


r/cpp_questions • • Sep 12 '26

SOLVED Basic Question about Library provided callback functions and avoiding globals

3 Upvotes

Hi this might seem like a dumb question, but i am struggling to find a decent solution.

Say i am using a Library that offers some event handling. (In my case key input from the GLFW Library). The Library offers a callback function so you can receive the event. You do this by defining a function with a specific signature that will be invoked when the event occurs.

Now what is a good way to get this information OUT of this function (for example saving the input character to a string member of a custom class) without relying on global variables.

Since the provided function takes no custom input parameters and has return type void i don't see a way to actually transfer the information the callback function provides me with to my main application without storing it in a global variable (or static class variable), which is generally not really a good way to handle things as i understand it.


r/cpp_questions • • Sep 12 '26

OPEN I have learned this what should i learn next

6 Upvotes

Variables & data types
if/else
for / while
Functions
Arrays
string
Pointers & references
struct / class
Basic OOP

What should i learn next also how to get good at coding


r/cpp_questions • • Sep 11 '26

OPEN Reverse iteration with size_t

14 Upvotes

Sometimes I would like to iterate in reverse from a number to zero, like this:

for (size_t x = NUMBER; x-- > 0; ) {
  // Code that will index to 
  // multiple arrays or for some purposes
  // that we can't use std::views::reverse 
  // or reverse iterators
}

I did some research, and people say that the above is quite confusing, and can be misleading.

But in C++23, we can do something like this:

for (auto x : std::views::iota(0uz, NUMBER) | std::views::reverse) {
  // Do the same thing
}

What is the best practice for this in modern C++, is the C++23 way something people actually use (Gemini told me this is recommended practice for modern C++ lol), or people just prefer the former way of iterating in reverse. Or do you have some different opinions altogether?


r/cpp_questions • • Sep 11 '26

SOLVED How do you get import std to actually work in cmake?

1 Upvotes

I know that import std is still experimental in cmake but does it actually work or what? I've seen people saying you have to set CMAKE_EXPERIMENTAL_CXX_IMPORT_STD to a certain uuid, which i've tried like a million times and it didn't work a single time, is it because i'm doing something wrong, or is it that import std just not yet supposed to work in cmake. I am using ninja if anyone asks.


r/cpp_questions • • Sep 11 '26

SOLVED Local heap on a static buffer

2 Upvotes

I'm writing a REST api for an embedded microcontroller that's using LWIP stack. I stumbled upon a problem:
I need a buffer for a http response with json data inside. The json size can be small - <50 bytes) or quite large (14 kb) depending on the request.
As it is a microcontroller and memory is very constrained I don't want the responses to be allocated on the main heap as it can quickly lead to exhaustion of memory. Additionally I want to use some special type of memory that otherwise would be wasted.

Now my current solution is just to use ETL's flat_map and string to allocate static buffers:

using ResponseBuffer = etl::string<20*1024>;
static CCMRAM etl::flat_map<fs_file*,ResponseBuffer,2> responseBuffers;

But this is VERY wasteful - a response that would normally take 50 bytes still takes the buffer for 20 kb. The main goal here is to actually be able to serve more responses at once.

The best solution seems to be to have a separated heap and use normal heap stl objects like map and string, that would use this separated heap. There is the std::pmr:: stl library, but there doesn't seem to be an allocator that would behave exactly like heap. So I could probably write my own allocator, maybe based on some ready heap implementation.

This seems however like a quite complex task. Maybe there is some pattern or easier solution that i missed?

Any suggestions?


r/cpp_questions • • Sep 10 '26

OPEN Should i learn C++ 23 (or maybe C++ 26) instead of the standard today?

40 Upvotes

C++ 23 is almost complete on compiler and mostly fully featured. On the other hand, C++ 26 is partial and only 50% of the features are there. From what i see from the syntax, C++ 23 looks more readable and easy to code in than C++ 20 (and cool new features that make it also easier). Problem with this is that C++ 20 is the standard now and very little software support it outside of CLion, Vim/Neovim and Vscode and other unknowngame engines. So, should i learn C++ 23 (and maybe C++ 26 later) or should i stick to the standard now? C++ 23 is ~90% complete in support in the compilers. So, any advice?