C++ - Reddit
Відкрити в Telegram
Stay up-to-date with everything C++! Content directly fetched from the subreddit just for you. Join our group for discussions : @programminginc Powered by : @r_channels
Показати більше228
Підписники
Немає даних24 години
-17 днів
+130 день
Архів дописів
227
I just open-sourced my firewall project – Sentinel Firewall (early, solo dev, feedback welcome!)
https://github.com/Manaf-DEV1/Sentinel-Firewall
https://redd.it/1umxm21
@r_cpp
227
Windows doesn't have fork(), so I faked copy-on-write with VirtualProtect + exception handling to snapshot an in-memory KV store
Was messing around trying to figure out how Redis does BGSAVE without blocking, and it comes down to fork() + COW on Linux — the OS shares pages between parent/child and only copies a page when someone writes to it. Windows has no fork(), so there's no free lunch here.
Ended up building a small toy project (Veyr) to see if I could fake the same behavior in user space on Windows. Wrote it up here if anyone's interested: https://satadeepdasgupta.medium.com/the-windows-machine-doesnt-have-fork-so-we-built-one-b10e1357aa4f
Short version of how it works:
• put the whole dataset in one big VirtualAlloc'd arena
• when snapshotting starts, VirtualProtect the arena to PAGE_READONLY
• any write thread that touches it now takes a hardware access violation
• catch that in a Vectored Exception Handler, copy the 4KB page to a shadow buffer before it changes, flip that page back to RW, resume execution
• background thread walks the arena and writes shadow pages for anything that got touched, live pages for anything that didn't
The first version I tried leaked memory into deadlocks because my handler was calling malloc for the shadow page allocation, and if the frozen thread happened to be holding the heap lock when it faulted, it just... never came back. Fixed by only calling VirtualAlloc directly inside the handler, never touching the normal allocator. Kind of an obvious fix in hindsight but took me a minute to figure out why it was randomly hanging.
Also built a lock-free hash map for it (atomic pointer swap per slot, immutable entries so there's no torn reads) since the snapshotting trick doesn't matter much if the map itself is the bottleneck.
Ran redis-benchmark against it and against Memurai (Redis-compatible Windows server) on the same box, same command. Veyr came out ahead by a decent margin but it's only doing GET/SET, no persistence format, no ACLs, none of the actual feature surface Memurai has, so take that as "minimal special-purpose thing beats general-purpose thing" rather than any real claim about which engine is better. Numbers are in the post if curious, didn't want to just paste a screenshot and let it become the whole conversation.
Known gap I haven't fixed: the map doesn't free old entries on overwrite, it just orphans them in a bump arena. Works fine for a benchmark, would leak forever under real sustained traffic. Need to add epoch-based reclamation or hazard pointers or something before this is anything other than a toy.
Source's up if anyone wants to poke holes in it: github.com/satadeep3927/veyr
Happy to be told I reinvented something that already exists, wouldn't be the first time.
https://redd.it/1umrgp6
@r_cpp
227
C++ Show and Tell - July 2026
Use this thread to share anything you've written in C++. This includes:
* a tool you've written
* a game you've been working on
* your first non-trivial C++ program
The rules of this thread are very straight forward:
* The project must involve C++ in some way.
* It must be something you (alone or with others) have done.
* Please share a link, if applicable.
* Please post images, if applicable.
If you're working on a C++ library, you can also share new releases or major updates in a dedicated post as before. The line we're drawing is between "written in C++" and "useful for C++ programmers specifically". If you're writing a C++ library or tool for C++ developers, that's something C++ programmers can use and is on-topic for a main submission. It's different if you're just using C++ to implement a generic program that isn't specifically about C++: you're free to share it here, but it wouldn't quite fit as a standalone post.
Last month's thread: https://www.reddit.com/r/cpp/comments/1tulp9b/c_show_and_tell_june_2026/
https://redd.it/1umnaxs
@r_cpp
227
is there any material available that do code review of projects?
Hi All
I am learning C++ and wants to create/contribute C++ projects.
I know most of modern cpp concepts(till c++17)
but haven't confidence and also I want to follow some clean coding standards.
If there any material related to code review available on YouTube/Udemy/Coursera or anywhere that will be very helpful to me.
so, please tell if anyone have experience into this
Thanks in Advance to all of you !!
https://redd.it/1umg42n
@r_cpp
227
Just had a fun one with copilot, while I was hating on the crypt32.dll API docs
Me:
>Microsoft needs to run the win32 apis through libabigail 😅
Copilot (GPT 5.5):
>🤣
>
>Honestly, libabigail would probably report something like:
>
>Type diff:
CERT_CHAIN_CONTEXT
member rgpChain changed from:
CERT_SIMPLE_CHAIN**
>
>Impact:
> 4,372 developers regained the will to live.
>
>The CryptoAPI headers are a spectacular example of APIs designed around:
>
>- C89
>- binary stability
>- minimizing copies
>- allocator flexibility
>
>rather than:
>
>- readability
>- type expressiveness
>- ease of interop
followed by it ripping into everything about that entire type hierarchy for... A while...
It made me feel better for a bit, at least.
https://redd.it/1um44mb
@r_cpp
227
Anyone using Claude to reverse-engineer legacy C/C++ systems? My sequence-diagram agents are missing or inventing call paths
I I inherited a legacy C/C++ software that lacks comprehensive documentation.
To address this, I’ve developed agents that generate sequence diagrams for specified features.
However, these agents have been implemented for numerous features, but they either don’t document every sequence or they document incorrect sequences and features for sequence diagrams.
Here’s what I’m doing to resolve this issue, but it’s not working.
1. I’ll create a top-level breakdown structure of the software stack and the current code.
2. I’ll identify the features that are part of the software stack and determine which specific API initiates those features.
Any input or help would be greatly appreciated.
https://redd.it/1ulzpuf
@r_cpp
227
Pure Virtual C++ 2026 lineup: free online conference on July 21
https://devblogs.microsoft.com/cppblog/pure-virtual-cpp-2026-talks-announced/
https://redd.it/1ulwhnz
@r_cpp
227
Part 2: Modernizing a tiny C++ unit-testing framework after 25 years
Recently I shared Part 1 describing a tiny unit-testing framework I originally wrote around 2000 for teaching C++.
Part 2 finishes the series by modernizing the implementation using facilities that didn’t exist back then, including
std::source_location and inline variables, while keeping the framework intentionally small.
This isn’t intended as a replacement for Catch2, GoogleTest, or doctest. Those solve much bigger problems. The point here is to explore how far modern C++ lets you go with very little code.
I’d be interested in comments from anyone who’s built testing infrastructure or has opinions about minimalist testing frameworks.
Part 2:
https://freshsources.com/code-capsules/test-part2/
Part 1:
https://freshsources.com/code-capsules/test-part1/
https://redd.it/1ulqvza
@r_cpp227
Why use c++ over c for game development?
Isn't c++ overkill for most games? I think with good architectural decisions you can make decent 2d and 3d games using only what's available in c without the higher level concepts introduced in c++? Do you think I'm being stupid here? Am I missing something? I'm only just starting to learn c making simple games leaning heavily on Raylib and ECS architecture.
https://redd.it/1uloq6g
@r_cpp
227
SoaTable: A header-only C++23 Structure-of-Arrays table with a row-shaped API
I've been working on SoaTable, a header-only C++23 library that stores data as a Structure-of-Arrays (one contiguous array per field) but keeps a row-shaped API on top: you insert() a record, assign<Column>() fields to it, and iterate with view<Position, Velocity>().
The goal was to get columnar/cache-friendly layout without
forcing the code that uses it to think in columns.
Repo: https://github.com/bbalouki/soatable
A few design points that might be worth discussing here:
1- Columns are sparse and optional per row. A record only pays for the fields it actually has. Data-less column types (struct Frozen {};) act as tags and cost \~nothing. Reading a missing field is a defined "not present", not UB.
2- Handles are generational. insert() returns a row_id that survives erase, insert, and full re-sorts, and a stale handle reports itself invalid instead of aliasing a reused slot (ABA).
3- Joins start from the smallest column. view/select<A, B>() scans the smaller of the two validity sets and probes the other, so selective queries touch far fewer rows.
4- Layout is a policy, not a rewrite. soa_table (flat, 64B-aligned), aosoa_table<Tile> (tiled, growth never copies), pmr_soa_table (arena/pool), and mmap_soa_table (larger-than-RAM) all share the identical row API.
5- Zero-copy escape hatch. column<T>() hands back a std::span over the real aligned storage for SIMD/BLAS/FFT, with a separate validity bitmap.
6- Opt-in everything. Core is one dependency-free header; compute, query/group-by, serialize, concurrent, timeseries, units, and a runtime dynamic_table are separate headers you include only if you use them. There's also a SOATABLE_NO_EXCEPTIONS / no-RTTI build for embedded/flight targets, kept honest by a dedicated CI leg.
Where it earns its keep: large, sparse tables with selective queries (ECS worlds, tick stores, telemetry).
Where it doesn't: if the table is small, every row has every field, and every pass touches every field, a plain std::vector<Struct> is simpler and just as fast. I tried to be upfront about that in the README.
Numbers (selective join, 250k rows, Release; machine-dependent, harness in the repo):
smallest-drawer select \~168µs vs \~1.55ms when forced to start from the largest column, vs \~1.06ms for a hand-rolled columnar scan and \~1.30ms for an AoS branch scan.
It is not an ECS framework (no systems scheduler, no archetypes), it's the storage layer, so it's more comparable to a sparse-set column store than to EnTT/flecs.
C++23 required (GCC 13+, Clang 18+, MSVC VS2022), CMake/Conan/vcpkg.
Feedback on the API, the sparse-column design, and the benchmark methodology is very welcome m, especially from people doing ECS or columnar-analytics work.
https://redd.it/1ulftvn
@r_cpp
227
Redundancy seen in AAA game engines
https://zero-irp.github.io/Redundancy-seen-in-AAA-game-engines/
https://redd.it/1uli202
@r_cpp
227
Meeting C++ online: Giving Students a space to present their C++ Projects
https://meetingcpp.com/meetingcpp/news/items/Giving-Students-a-space-to-present-their-Cpp-Projects.html
https://redd.it/1ulbs12
@r_cpp
227
I’m 17, I love C++, but I feel lost trying to get my first remote programming job
I’m 17 and I genuinely love C++ because it is difficult in many ways. It constantly challenges you to think deeply, and it has a wide range of applications, like robotics, game development, embedded systems, and similar fields.
The problem is that all of these jobs seem extremely hard to find, especially for someone my age. I don’t really know what to do. I would love to get my first remote job, but there are almost no opportunities, at least from what I see on X/Twitter. A friend recommended cold emailing, and some people I know said they got jobs that way, but I honestly don’t know how to approach it.
I don’t know if I sound pessimistic, but programming has become the center of many jobs that attract scammy behavior. Sometimes I feel like, in the job market, I will be treated the same as someone who just watched a YouTube video, heard that programmers are highly paid, and decided that programming is a great work-from-home career.
There are just too many of us.
When I think about how many people I knew on Discord who were depressed and only wanted a remote job so they could use AI to do the work, it makes me feel even more confused. Then I look at people on YouTube,Instagram,tik-tok making money from the most ridiculous things, and it honestly feels like people today don’t even think deeply anymore.
Times feel very hard, and I don’t know what I should do.
My friends told me to try cold emailing, and they say they got work that way, but I really don’t know what I am supposed to become in today’s world: a good person and a real programmer, or just another scammy person who only wants money, like it feels many people are doing now.
I know this might sound negative, but I’m being honest. I like programming, especially C++, and I want to build real skills. I just don’t know what the realistic path is for someone who is 17, has no degree, wants remote work, and is interested in hard fields like robotics, game dev, embedded systems, or low-level programming.
Any honest advice from people who have been in a similar position would mean a lot.
https://redd.it/1uktsh3
@r_cpp
227
Request for feedback on an AI framework that I coded in my free time.
I've spent several months developing a C++ AI engine with a runtime, planner, memory management, and multi-language scripting. I'd like some feedback on the architecture.
https://github.com/brit45/mimir-framework.git
https://redd.it/1ukukz5
@r_cpp
227
Learning about Asymmetric Fences and its Underlying Mechanism - Membarrier
https://nekrozqliphort.github.io/posts/membarrier/
Hey, everyone! You might remember my previous write-ups on \[\[no\_unique\_address\\]](https://www.reddit.com/r/cpp/s/YwbtMBDgz9) and strongly happens before. It took a few months of researching but I finally have a draft version of my new write-up on asymmetric fences (hopefully building up to a write-up on RCU).
This write-up essentially goes into what asymmetric fences are supposed to achieve, its underlying mechanism (the membarrier syscall), and the wording in the standard. Special thanks to u/davidtgoldblatt for his insights and discussions regarding this topic!
Feel free to provide any feedback! This one is denser than my usual write-ups, but I hope you'll find it interesting and insightful.
https://redd.it/1ukskdo
@r_cpp
227
Pystd standard library, similar-ish functionality with a fraction of the compile time
https://nibblestew.blogspot.com/2026/06/pystd-standard-library-similar-ish.html
https://redd.it/1ukpss9
@r_cpp
227
Rate my code!
#include <stdio.h> #include <string.h> #include <iostream> #include <filesystem> using namespace std; namespace fs = std::filesystem; using S = string; using H = const unsigned char; using F = void()(); using G = S()(); using D = void()(fs::path); using Q = void()(S); template<int N, int K> struct Z { S d(H h) { S r; int key = K; for(int i = 0; i < N; i++) { r += char(h[i] ^ key); key = (key 0x5F + 0x13) & 0xFF; } for(char &c : r) c = (c ^ 0x7F) - 3; return r; } }; S b(H h, int n) { S s; for(int i=0;i<n;i++) s+=char(hi); return s; } struct Obf { void o(S x) { cout << x; } S i() { S t; cin >> t; return t; } }; bool d(S p) { return fs::isdirectory(p); } void l(fs::path p) { for(auto& e : fs::directoryiterator(p)) cout << e.path().filename().string() << '\n'; } Obf ob; void e() { ob.o(b((H)"\x73\x6f\x72\x72\x79\x20\x77\x65\x20\x63\x6f\x75\x6c\x64\x20\x6e\x6f\x74\x20\x66\x69\x6e\x64\x20\x79\x6f\x75\x72\x20\x64\x69\x72\x65\x63\x74\x6f\x72\x79\x0a",38)); } void r(S p) { d(p) ? l(p) : e(); } S g() { return ob.i(); } F vf32; G gf8; D df8; Q qf8; void s1() { ob.o(Z<76, 0x37>().d((H)"\x4f\x5a\x58\x4e\x4b\x4e\x20\x60\x65\x5e\x52\x52\x20\x5d\x5e\x20\x5e\x5e\x63\x5e\x20\x57\x5d\x5e\x55\x5e\x5e\x5f\x5e\x20\x5e\x5f\x20\x5e\x5e\x5f\x20\x27\x2e\x2e\x27\x20\x5a\x5e\x5f\x20\x60\x5d\x5d\x5e\x27\x60\x20\x5f\x63\x5f\x5f\x5e\x5e\x5f\x20\x57\x5d\x5e\x55\x5e\x5e\x5f\x0a")); S x = gf0; x == "CD" ? vf9 : qf0; } void s2() { vf10; } void s3() { df0); } void s4(S p) { qf1; } void s5() { ob.o(b((H)"\x0a",1)); } int main() { vf0 = s1; vf9 = s3; vf10 = s2; df0 = l; qf0 = r; qf[1] = s4; gf[0] = g; vf0; s5(); return 0; }
https://redd.it/1ukn1v3
@r_cpp
227
Can windows devs provide us with a visual studio sdk in a tarball/zip form?
Currently, in order to cross compile to windows properly we either download visual studio in a windows machine, copy it's contents to our machine and pass /winsysroot to clang-cl or it's equilevent gnu flag.
Or we use msvc wine to download using wine and deal with capitalization issues.
Why can't windows devs provide us with something similar to msvc wine? It would really simplify getting sysroots to setting up your toolchain.
I filed a ticked to but didn't heard a reply. If anyone here can raise awareness on this issue it would help the whole community.
https://redd.it/1ukm4g0
@r_cpp
227
What's the fastest c++ build pipeline you've achieved ?
Trying to get a realistic picture of what's actually achievable on a large c++ codename before we commit to anything. We're at 450k LOC, full clean builds sitting around at 55 minites on a 16-core machine. Incremental builds are manageable but a full rebuild after a branch switch or a CI run is painful. We've moved to Ninja, cache is in place, worst of the header bloat is cleaned up. At this point it feels like We're pushing against a hardware ceiling rather than a tooling one. Distributed compilation seems like the logical next move , but I'm also wondering if there's something between local optimizations and a full distrubuted setup that actually moves the needle. Anyone hit similar numbers at this scale and seen meaningful improvements?
https://redd.it/1uklb9y
@r_cpp
227
Modern GPU Programming with SDL3, Wed, Jul 8, 2026, 6:00 PM (MDT)
https://www.meetup.com/utah-cpp-programmers/events/315322571
https://redd.it/1uk0k8y
@r_cpp
Вже доступно! Дослідження Telegram за 2025 — головні інсайти року 
