r/cpp_questions

Does anyone use old versions of Visual Studio?

I've been using Visual Studio since VS2019. The intervening releases (VS2022 and VS2026) don't feel much different to me, they all have the same problems:

  • Editing too many files (a few dozen) causes either devenv.exe or vcpkgsrv.exe to consume abnormally high CPU. I must close all files (and lose undo history) to get them back to normal
  • Constantly trying to ping the internet. For example BackgroundDownload.exe randomly consumes 20% CPU despite being blocked by the firewall, deleted from task scheduler, and disabled in the registry. VS2026 even has a "retirement" date, a popup informed me today that I'll no longer be able to use it past that date without updating.

I've heard good words about old versions of VS, but I don't know if they are still usable today. The most important to me is using them with the newest compiler and toolset. Existing solutions also need to be made compatible with old formats. Does anyone still use old VS, what's the experience like? Are there features you miss?

reddit.com
u/mbolp — 1 day ago

How can I instantiate a template with a type determined at runtime?

Hello,

I need to instantiate a std::vector, but its type depends on something that I would not know until runtime:

#include <vector>
if (some_condition)
std::vector<float> myVector;
else
std::vector<int32_t> myVector;

I know this does not work because,in order to instantiate a template class, the data type must be known at compile time.

I've seen some people suggest std::variant but I have not understood it completely.

Also, how do different libraries (like ONNX) provide different data types? Do they use templates?

PS : I am not developing a library.

EDIT:

I need to create an array or a vector to act as a placeholder (allocator) for input tensors. But this vector requires a different amount of space based on the size and type of the input. The size is easily manageable per instance of the parent class if we only had one type, but we don't.

The thing is, there are some arguments that need to be set for this specific project that determine what exactly the size of the array would be, and they are only known when you parse an ONNX model at runtime.

reddit.com
u/CommandShot1398 — 1 day ago

How would you get clangd to work with bits/stdc++.h?

Hello

My use case is writing competitive programming solutions in c++. i use neovim with the clangd lsp server. but i just cant get it to work with gcc header files, `bits/stdc++.h` in my case.

i have tried:

```

CompileFlags:

Add:

- -std=gnu++17

- -I/opt/homebrew/Cellar/gcc/16.1.0/include/c++/16

- -I/opt/homebrew/Cellar/gcc/16.1.0/include/c++/16/aarch64-apple-darwin25

```

it just doesn't work. it starts giving me duplicate definition errors once i add these compileflags.

reddit.com
u/PleasantMix6193 — 1 day ago

Is C++ systems programming too fragmented for hiring?

I recently saw a manager reject a candidate we were interviewing because his experience didn't exactly match the specific sub domain.

But I found myself disagreeing with the philosophy behind the rejection. My instinct is that if someone has strong C++ skills and has worked on reasonably complex systems, you should at least ask: "Can this person learn the domain?" rather than requiring an almost exact match.

This made me wonder whether this is a particular problem with systems programming in C/C++.

The ecosystem seems incredibly fragmented:

  • Embedded
  • Linux kernel/drivers
  • Graphics
  • Multimedia/codecs
  • Databases/storage
  • Networking
  • Telecom
  • Game engines
  • Server/backend infrastructure
  • Qt/GUI
  • Compilers
  • etc.

Someone can have spent 8 years writing sophisticated C++ in one of these areas and still be considered a poor candidate for another area because they don't have the specific domain experience.

Compare that with web development, where the skill boundaries seem somewhat easier to communicate: "React developer", "Angular developer", "Node.js backend developer", etc. There are obviously specializations there too, but the fragmentation doesn't feel as extreme.

I personally have the philosophy that if someone knows C++ well, understands systems programming concepts, debugging, memory, concurrency, Linux, etc., they should be given some credit for being able to move between domains. The domain-specific knowledge can be learned.

I have faced this exact issues with companies too. They reject you because haven't worked specifically on what they do. This becomes a serious issues when it's already hard to get into C++ jobs. Has anyone faced similar issues? What exactly is the solution for this?

reddit.com
u/kyan100 — 1 day ago

Seeking alignas intuition and resources

Hi, all:

I've been experimenting with alignas after reading this post. Applying it is unintuitive to me, I'm not sure when I'd use this optimization method other than just trying it and measuring. From the article:

> Another important thing to note is that read (readIdx_) and write (writeIdx_) indices are aligned to the size of a cache line (alignas(64)). This is done to reduce cache coherency traffic. On AMD64 / x86_64 and ARM a cache line is 64 bytes, on other CPUs you need to adjust to the appropriate alignment, using std::hardware_destructive_interference_size is a good choice if it’s available. It can also be interesting to try aligning to a multiple of the cache line size in case adjacent cache lines are being pre-fetched.

Is it really as simple as aligning your structs and members on 64 bytes? I'm looking for some more reading on the subject.

Thanks

reddit.com
u/SadPonyGuerrillaGal — 24 hours ago
▲ 3 r/cpp_questions+3 crossposts

grm: telegram CLI project in C++

grm: telegram CLI that is Human and AI friendly repos:

Features:

  • Dual Human/AI UX Engine: Optimized both for interactive terminal use (ANSI TTY tables, color schemes) and automated AI agent workflows (JSON envelope, NDJSON streams).

  • Native TDLib Engine: Direct C++ bindings to libtdjson for zero-hallucination, full MTProto protocol fidelity.

  • Supergroup & Forum Topic First: Complete lifecycle management for Telegram Supergroups, Forum Topics, custom emoji icons, and thread messages.

  • File Upload & Download Engine: Streamlined document, photo, video, and media extractions with MIME detection and progress tracking.

  • Shell Tab Auto-Completion: Context-aware Bash tab completion covering commands, subcommands, flags, and options.

  • Telegram Rich Text & Emoji Customization: Telegram Markdown V2 entity formatting and custom Supergroup topic emoji icons.

  • FreeDesktop & XDG Compliant: Strictly honors FreeDesktop standards for user binaries, man pages, shell completions, and session state.

Im just having fun with it. I have a roadmap so check it out. I'll see how much time I can dedicate to this one.

It's already pretty cool, at least for me. The --filter and --since options are killers.

It's pre alpha stuff. Use it under your own peril.

I had to compile my own libtdjson and put it in ~/.local/lib:

$ ldd ~/.local/bin/grm 
	linux-vdso.so.1 (0x00007f69897ba000)
	libtdjson.so.1.8.0 => /home/someuser/.local/lib/libtdjson.so.1.8.0 (0x00007f6987400000)
	libjson-c.so.5 => /lib64/libjson-c.so.5 (0x00007f698976b000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f6987000000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f69872e9000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f698973e000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f6986e07000)
	libssl.so.3 => /lib64/libssl.so.3 (0x00007f6986d0e000)
	libcrypto.so.3 => /lib64/libcrypto.so.3 (0x00007f6986600000)
	libz.so.1 => /lib64/libz.so.1 (0x00007f6989712000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f69897bc000)

Login works at least... sometimes. ;D

Demo:

$ time grm chat ls
CHAT ID              TYPE            TITLE                          UNREAD
---------------------------------------------------------------------------
-1003950065700       Supergroup      Domadores Digitales            0
-1002549279967       Supergroup      EVALinux Bar!                  0
-1002312480906       Supergroup      NorTK                          0
-1002289735000       Supergroup      EVALinux                       0
-1003981300643       Supergroup      (expert) creations             1
-1001623037840       Supergroup      Linux En Español               9
-1002527874209       Supergroup      Fundación MxOS                 0
-1001981848857       Supergroup      NubeMX                         0
-1003679369169       Supergroup      Hyper Muscles & Boobs Heaven   36
8911035898           Private Chat    Abastero                       0
-467666877           Basic Group     Proyectos 1101                 0
-1003596396470       Supergroup      1101 SOPORTE VALLEJO           0
-1001371756065       Supergroup      Fedora Linux                   3
6943468991           Private Chat    Doris Marian Jiménez Beltrán   0
777000               Private Chat    Telegram                       0
-1001127772209       Supergroup      DeviantArt                     0
-1001382463627       Supergroup      Team Offtopic buscando popularidad en el barrio del baneado 0
-1002234007248       Supergroup      Naomilk 🐰🔞                   0
-1001100311770       Supergroup      Fedora México                  0
-1001789902965       Supergroup      Los Bonitos                    1

real	0m0.063s
user	0m0.047s
sys	0m0.030s

$ time grm msg ls --filter='@renich' --limit=2 --since='3 years ago' -1001100311770
(2023-08-16T00:39:26Z) <@renichbon> : Ah, un comando para resetear todas mis configuraciones de GNOME:
                                      
                                      dconf reset -f /
                                      
                                      
                                      Úselo bajo su propio riesgo.
(2023-08-26T23:26:58Z) <@renichbon> : OpenTF Foundation
                                      https://opentf.org/announcement
real	0m0.484s
user	0m0.045s
sys	0m0.025s

real	0m0.484s
user	0m0.045s
sys	0m0.025s
u/Renich — 1 day ago

Learning c++

So I'm doing dsa in c++ as well as learning modern c++ concepts.I want to become c++ developer what concepts should I learn to become a c++ developer , what concepts should I focus on , what are the best resources to learn c++.Also when I try to build something in c++ i don't even know where to start.Its been 4 months I learned C++ and I'm genuinely comfortable with it till now.

reddit.com
u/Notsoboringi — 1 day ago

How can i become an expert in cpp

I started with c++ 3 years ago but real work was 1 and a half years, i learned a lot about cpp syntax and the std lib, but whenever i make some code and send it to an ai model, it says my code has a lot of issues some about dynamic memory some about references and pointers some c-style programming and i find myself Ignorant most of the time

So how can i learn these things and the rules of the language and understand them(i dont watch YouTube) I have started with learncpp.com recently

"Sorry if it's a duplicate post and for it being long if its a duplicate point me to one, and thanks"

Edit: my github is loadingSy if you would like to check anything, I learned git 1 month ago

reddit.com
u/Unique-Willingness15 — 2 days ago

What topics should I focus on from learncpp?

I’ve been working through learncpp from about 2 weeks now and I’m wondering if people have suggestions on topics that are a MUST to learn for an engineer that is coming from Python/TypeScript?

For context I work as a software engineer, primarily using Python and TypeScript, so I have a good base understanding of how to build a program or applications, however, I want to focus more on the specific nuances of C++ and concepts that are maybe abstracted away in higher level languages.

A list of topics in order of importance and increasing complexity would be a great help!!

reddit.com
u/Outside-Highway6967 — 2 days ago

How can I catch up on missing multithreading experience?

Hi everyone 👋, I’m a C++ developer with 5+ years experience building features for a single-threaded trading app (C++17), so I have very little multithreading experience.

I’m currently reading C++ Concurrency in Action. Are there good resources or projects to practice real-world scenarios like backloading and low-latency concurrency patterns?

reddit.com
u/detectivesokka — 3 days ago

Heavy and Light Objects

When I was first learning C++, I experienced massive slowdown when allocating dynamic memory. Ever since then I divide my objects between 'heavy' objects that allocate resources, and 'light' objects that can be used as temporaries on the stack. Heavy objects cannot be copied at all, must be allocated somewhere once, and then passed by (const) reference. Light objects can be copied, created quickly on the stack etc.

Since C++11 it has been possible to write copy and assignment constructors that take nameless objects, and since they are nameless you can pillage their pointers and avoid expensive stack allocations. All is well then but if you keep to this strict 'heavy' and 'light' object idea, _any_ object that allocates resources is considered a heavy object. The first allocation in the chain, before you just pillage pointers, is still an expensive stack allocation so I would consider it a 'heavy' object and just make it impossible to copy at all, by removing all copy and assignment constructors. And so using this model I never needed those nameless object reference constructors.

Anybody feel the same way?

reddit.com
u/ParmenidesWasRight — 3 days ago

How to fix errors LNK2005 and LNK1169 in Visual Studio?

Hi! I’m a beginner programmer learning C++ and getting to grips with Visual Studio 2026. For some reason I can’t run the console because of two errors: LNK2005 and LNK1169 (or perhaps there are others, but I’m not sure). I’ve attached below the error messages I’m getting step by step (links to imgbb). I’ve asked some AI chatbots for advice on how to solve this problem, but nothing’s working.

Firstfoto, Secondfoto, Thirdfoto

Thanks in advance for your help!

u/Kawafilya_reptiloid — 2 days ago
▲ 0 r/cpp_questions+2 crossposts

Made a video explaining how memory ACTUALLY works in C++ (Stack vs Heap, new/delete) — feedback welcome

Hey everyone,

I put together a video on Dynamic Memory Allocation in C++ — part of an OOP series I'm building for people prepping for interviews/DSA who want solid fundamentals, not just surface-level definitions.

Covers:

  • Stack vs Heap — the real differences, not just textbook definitions
  • Why taking array size as user input on the Stack is a bad idea (and often breaks across compilers)
  • How new actually allocates on the Heap at runtime
  • Why you need a pointer on the Stack to access Heap data
  • Using delete properly to avoid memory leaks

I tried to explain the "why" behind these concepts since most tutorials just show syntax without explaining what's actually happening in memory.

Link: https://youtu.be/JxrYh3xUF54

Would love feedback — anything unclear, anything you'd want covered next in the series (constructors/destructors, virtual functions, etc.), or just general thoughts. Not trying to spam, genuinely want to make this series useful.

Thanks!

u/Silver_Court_3399 — 3 days ago

Is this book up to date?

Hello so I found this book but because no pictures:

[Sam's teach yourself c++ in 21 days, fourth edition]

[2001]

So did c++ get any updates in 25 years?

reddit.com
u/d1tt01 — 3 days ago

Basic question, but does initializing a pointer always initialize it to null?

Are these two lines any different in practice? (Especially if you want to later check if x has been given a specific address, or if it's still null.)

int* x {};

int* x { nullptr };

reddit.com
u/playsthebongcloud — 4 days ago

ELI5: Why does the random output once but TIME fixes it

>The examples above just outputs a random number once. They don't output different random numbers each time the program runs. To fix this, you can use the srand() function and add the time() function from the <ctime> library. ~ W3School

>
Generally speaking, the pseudo-random number generator should only be seeded once, before any calls to rand(), at the start of the program. It should not be repeatedly seeded, or reseeded every time you wish to generate a new batch of pseudo-random numbers. Standard practice is to use the result of a call to std::time(0) as the seed. However, std::time returns a std::time_t value, and std::time_t is not guaranteed to be an integral type. ~ cppReference

I do not understand why time changes it and I do not understand the seed and what it is

reddit.com
u/TheEyebal — 4 days ago

Best Way to Collect Initialization Actions using C++ Capabilities?

I'm writing a scripting language with additional functions that can be built in.

The built-in functions would be written in C++ for speed.

In different builds of the scripting language, some functions might be omitted.

So, I'm looking for the best way to automatically collect, at compile time or early at execution time, the full list of extra built-in functions, so that the script interpreter can parse and execute a script (to do this, it has to know about any additional capability compiled in).

For example, in Visual C++, I'd like to simply add a source file containing built-in scripting language functions, and have the script interpreter know they are there.

My goal would be no additional configuration actions other than adding the source file to the project (in other words, no need to modify other files). The software should somehow figure out that additional script built-in function capability is in the build.

Google Test seems to do this somehow with a macro like TEST_F, but I'm not sure how this works under the hood. The list of tests is somehow collected automatically at compile time or early at run time.

To give some practical background ... decades ago I did some work extending the Tcl scripting language. It was only necessary somehow in initialization to call a command to "register" a new function available to the script interpreter, but the source code had to be modified manually to include the additional initialization. The manual modification is what I'm trying to avoid.

Is there a standard design pattern for this in C++?

reddit.com
u/DaveInTheMidwest — 4 days ago

Is C++26 ready to use in a Production Enviroment?

C++ 26 adds a ton of great features, but how is compiler coverage, usabillity, integration, etc. for those features right now?

reddit.com
u/No-Foundation9213 — 4 days ago