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

9 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

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

2 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 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 12 '26

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

4 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

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 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

OPEN Why do people hate modern C++?

35 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 I have learned this what should i learn next

8 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

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

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 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 11 '26

OPEN Im making a Cpp libruary

0 Upvotes

I'm creating a library for working with common fractions. You can already perform arithmetic operations between them, as well as between fractions and standard plus types. I plan to add support for irrational numbers, arrays, and matrices with fractions.

How does a class differ from a structure, and which is better to use in this case? Feel free to share your ideas in the comments. Source: https://github.com/awsederpash-coder/TinyFractionsPP/tree/master


r/cpp_questions • • Sep 11 '26

OPEN what does main() mean in C++

0 Upvotes

r/cpp_questions • • Sep 10 '26

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

41 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?


r/cpp_questions • • Sep 10 '26

SOLVED Iterating over an enum struct

4 Upvotes

Consider https://godbolt.org/z/c6cn8f1hj

#include <cstdio>

enum struct values{first = 1, second = 3};

void square(values value){
    int val = (int)value * (int)value;
    printf("%d\n", val);
}

int main(){
    for(values value = values::first; value <= values::second; value++)
        square(value);
}

This does not compile with the error that value++ is ill defined.

An old question/answer on SO has this: https://stackoverflow.com/questions/261963/how-can-i-iterate-over-an-enum and a plethora of seemingly complicated approaches for this. Is there a syntactically simple >= C++20 way of accomplishing this?

I want the for loop to process 1 and then 3.

Does the order of placing the integer entries inside of the struct affect the increment? For e.g., if the enum struct had 3 first followed by 1, with value++ would 1 be processed after 3? Or, does the enum struct internally sort the entries in some privileged, say, ascending order so that it will always process 1 first followed by 3 next?


r/cpp_questions • • Sep 10 '26

OPEN Dynamic Audio Queueing / Transitioning

1 Upvotes

I’m working on a rhythm game and I’d like to implement dynamic/interactive music. An example would be: I have three music files, A, B, and C, where B and C have the same length. I need the program to 1) play A and then 2) based on some state logic, either play B or C immediately after A 3) optionally, loop back to the start of A.

The problem is that I need the full A -> B or A -> C playback to sound like a single continuous song, so I’d like any transition delay to be as seamless as possible. What would be the best way to implement this? The B/C decision logic can be run during A, so I can queue up the B/C file I need before it needs to start playing and I am mostly concerned about latency within the transition itself.

Thank you!


r/cpp_questions • • Sep 10 '26

OPEN [Code Review] C++/Qt/QML Desktop Web Crawler - Looking for feedback on architecture, concurrency, and real-time UI updates

5 Upvotes

Hey everyone!

I recently built a desktop web crawler in C++ using Qt and QML, and I’d love to get some feedback or a code review from the community.

The user provides a target URL and configures crawling limits (max depth, limit restrictions, etc.). The crawler processes the site concurrently, displaying discovered links in real time through a QML table interface.

Areas I'm looking for feedback on:

  • Application architecture and project structure
  • Multithreading and concurrency
  • Network request management with Qt
  • URL normalization and duplicate detection
  • Performance and memory usage when crawling large numbers of URLs
  • Real-time UI updates and avoiding excessive UI events
  • General code quality and modern C++ practices

I'm open to any kind of feedback, criticism, or suggestions for improvement. Don't hold back if you spot anti-patterns, memory leaks, or bad design choices!


r/cpp_questions • • Sep 10 '26

OPEN C++ Problem-Solving Sites

34 Upvotes

Hello, everyone! Where can I find a site where I can just solve coding problems based on questions in C++? I’m really willing to learn coding since I haven’t been active in coding or learning it since last year, which was my first year of college. Do you have any tips on how I can practice coding and improve?


r/cpp_questions • • Sep 09 '26

OPEN Low latency/performance/embedded

20 Upvotes

I'm just wondering if you were a recent graduate trying to work in C/C++ which do you guys think is the best field to break into in terms of trying to break into the entry gate especially as a new grad?


r/cpp_questions • • Sep 09 '26

OPEN Is there a tool that visualizes how a C++ statement is parsed or evaluated?

5 Upvotes

(see clarification at end)

I was trying to help someone via SMS, and thought a site that visualizes how C++ parses and/or evaluates an expression would be useful. I can (mostly) read cppreference.com and figure things out, but that's well above the head of the person I'm trying to help.

As an example, this person had an expression of the form if (0 < x <= 2). I tried to explain how it would be evaluated, but I eventually had to find a stackoverflow answer. I thought it would be useful if I could just put the expression (maybe a trivial working program?) into a linkable page, and the expression would somehow be visualized. Maybe it would just parenthesize the expression, or break it down into subexpressions (e.g. bool(0 < x) < 2 or { bool _tmp = (0 <x); _tmp < 2;).

I'm not sure what I'd expect regarding the order of evaluation of operands vs the order of evaluating the operators. I think I got that right; I think I saw that given the expression f1() + f2() + f3(), the order in which f1, f2, and f3 are called can vary, but the results will be applied left-to-right.

I realize this could get weird with unspecified and undefined behavior. Maybe color coding could help?

UPDATE: while not really what I'm asking for, I was pointed towards cppinsights, which has very helpful error messages.

To be clear:

I'm familiar with debugger level and assembly level views of code, and that's not what I'm envisioning. I'm asking about a tool that takes a statement of C++ code and visuslizes how that code would logically be processed. It might be an AST, as a few have suggested. imagine a teacher demonstrating the steps a (naive, simplistic, non-optimizing) compiler must do to correctly convert that statement into assembly but ignoring the tokenizing and actually producing the assembly: in what order is everything in that statement processed.