C++ - Reddit
228 subscribers
48 photos
8 videos
25.3K links
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
Download Telegram
Module setup guide for clang/LLVM + vscode stack + cmake

I was searching the interweb for any actual guide on how to setup modules with import std and everything.


Sadly i couldn't find any in my reasonable 10 minutes of googling that guides and explains on all the steps, a tutorial per say ( im not / didnt using AI )

I added cmake at the end in the title because from what i understand this is needed always currently with modules?

Can anyone guide me here on what's needed to move into the future brrr.

https://redd.it/1u93gw2
@r_cpp
Project TSAR-MCP: A Zero-Dependency Orthodox C++ Framework for Edge AI. Because I write DB drivers for a living and AI was getting away from me.

Hi everyone,

Out of Minnesota 26 years ago IBM sent me to Germany, into a basement (truly) on-site at SAP in Walldorf to port kernels to run on IBM hardware (mostly on IBM i, the predecessor AS/400; but also database drivers for SAP application servers on everything else).

That's the background, the consequence is everything I do is written in C++ — mostly because I know and love it, but also because anything we ship needs to be self-contained. Intrigued by giving AI hands, I WANTED to make MCP servers I could use on-site and ship; therefore, I NEEDED to do it in C.

A true story before I sign off: In January I opened up Gemini and said, "I want to build a helloWorld MCP server in C."

The AI replied: "That will be somewhat difficult, there are easier ways."

I asked, "Why is it difficult??" (the second '?' was a bit of my ego).

Gemini replied: "Well, you'll need to parse JSON, handle raw I/O, and return strict JSON-RPC back to the client."

I told it, "One moment, let me show you something." (again my ego), I attached my JSON parser engine file (JSONParser.h) and said, "We have a JSON parser." (I typically talk to an LLM as a colleague working on the same project—for a reason, but that's a different story). This BNF parsing engine, by the way, is based on the same bedrock that powers our database driver (with SQL grammar, of course) built almost 2 decades ago.

Amusingly, the AI read the code and completely shifted its tone: "Oh, well then it's not so difficult."

My helloWorld became serious when I realized, with stdio over ssh, I could deliver an mcp endpoint in the SAP kernel to have it available on every database or remote application server running SAP. MCPServer_sapControl is my vision; approval is a different matter, but nevermind. Being enterprise-ready, TSAR-MCP-based servers are self-diagnosing — verbose operational traces are exposed to the client LLM, meaning even remote servers show the client what goes right and what goes wrong.

Enough details to bore you, the rest of the history is visible in the repository which I tagged with three teaching versions: the first is a simplistic sequential helloWorld MCP server that works out of the box; the second, an aspect server which does the same; the third tag is the version it is today — a fully asynchronous sampling MCP engine. The head version includes a full set of boilerplates.

I hope someone finds it useful, and I'm here for discussion if anyone wishes to.

Repository: https://github.com/IBM/tsar-mcp

Project Pages: https://ibm.github.io/tsar-mcp/

Cheers,

... Eric

https://redd.it/1u98a2y
@r_cpp
What is the point of Emscripten?

Lately I was writing a manual for building my development environment incase I need to build it again.

​

I look at the platforms I want to target, and see Emscripten, for wasm32 and wasm64. Lately, I saw an article, saying that all major browsers have supported wasm64 besides safari, and I don't care about Mac users so I thought why don't I just target wasm64, I don't really want to think about going over 4GB anyway.

​

The problem is, I really want to get to multi language language projects, and rust doesn't have an Emscripten backend for 64 bits. It has one for 32 bits only.

​

That got me thinking, why am I even doing this, why should anyone run compute intensive stuff from a browser rather than just downloading a binary. I really feel like it doesn't really solve real problems.

​

Most stuff that people ported to web via emscripten is disgustingly slow, and they have zero toolchain control unlike native development. I can't just build a standard library of my choice from source and use it. Neither can I just use another allocator. It is all a giant black box.

​

I mean, android development is also annoying, but libraries like SDL just give you the wrappers normally, and the way you build stuff makes sense, you build C/C++ parts normally and just run another build on top of that with gradle and friends.

​

​

https://redd.it/1u9hee6
@r_cpp
Built over a decade a turing-complete Quantum Computing zachlike

Hi
Excited to be able to announce that QO is almost ready to leave Early Access! I published a large patch that covers more than a year of work (lots of analytics, I've been tracking where ppl were getting stuck).

If you are interested in a highly intuitive visual method that faithfully describes all universal quantum computing and physics behind, (including how time behaves) this is for you. I am the Dev behind Quantum Odyssey (AMA! I love taking qs) - worked on it for about 10 years (3.5 in phd), the goal was to make a super immersive space for anyone to learn quantum computing through zachlike (open-ended) logic puzzles and compete on leaderboards and lots of community made content on finding the most optimal quantum algorithms. The game has a unique set of visuals (that was actually my PhD research) capable to represent any sort of quantum dynamics for any number of qubits and this is pretty much what makes it now possible for anybody 15yo+ to actually learn quantum logic without having to worry at all about the mathematics behind.

This is a game super different than what you'd normally expect in a programming/ logic puzzle game, so try it with an open mind.

# Stuff covered

Boolean Logic – bits, operators (NAND, OR, XOR, AND…), and classical arithmetic (adders). Learn how these can combine to build anything classical. You will learn to port these to a quantum computer.
Quantum Logic – qubits, the math behind them (linear algebra, SU(2), complex numbers), all Turing-complete gates (beyond Clifford set), and make tensors to evolve systems. Freely combine or create your own gates to build anything you can imagine using polar or complex numbers.
Quantum Phenomena – storing and retrieving information in the X, Y, Z bases; superposition (pure and mixed states), interference, entanglement, the no-cloning rule, reversibility, and how the measurement basis changes what you see.
Core Quantum Tricks – phase kickback, amplitude amplification, storing information in phase and retrieving it through interference, build custom gates and tensors, and define any entanglement scenario. (Control logic is handled separately from other gates.)
Famous Quantum Algorithms – explore Deutsch–Jozsa, Grover’s search, quantum Fourier transforms, Bernstein–Vazirani, and more.
Build & See Quantum Algorithms in Action – instead of just writing/ reading equations, make & watch algorithms unfold step by step so they become clear, visual, and unforgettable. Quantum Odyssey is built to grow into a full universal quantum computing learning platform. If a universal quantum computer can do it, I aim to bring it into the game!

Streams to watch:

khan academy style tutorials on qm/qc: https://www.youtube.com/@MackAttackx

Physics teacher wholesome stream with over 500hs in https://www.twitch.tv/beardhero

https://redd.it/1u9xyrq
@r_cpp
Efficient C++ Programming for Modern 64-bit CPUs, Chapter 4/part 2

Here comes the 2nd installment of (VERY DRAFT) Chapters from my (and Dmytro Ivanchykhin's) upcoming book, "Efficient C++ Programming for Modern 64-bit CPUs". Comments are extremely welcome (as before, we're committed to fixing all the issues highlighted in comments).

Second part of Chapter 4 (the one on CPU Physics and CPU Cycles): https://6it.dev/blog/infographics-operation-costs-in-cpu-clock-cycles-take-2-80736 . In addition to some interesting data (in particular, micro-research on the progress of MUL/DIV ops since 2017), it has that visualization of the different times quite a few ppl here have asked for.

DISCLAIMERS:

\- it is VERY DRAFT (editing is coming)

\- this is not a book on optimizations (though some techniques will be covered in Appendices A and B in Vol. 2) - this is a book on de-pessimizations; for optimizations - please refer to the excellent book by Denis Bakhvalov (though we're sure that de-pessimizations should be seen as a prerequisite for optimizations 😉).

https://redd.it/1u9yi15
@r_cpp
I want to make a mine sweeper in cpp but i dont know which gui to use

I thought about making a wpf gui and connect it to a cpp engine but i dont think that with wpf i can make a fun GUI, i really want it to look like a game and not a form

Do any of you have reccomendation for me?

https://redd.it/1u9zh1p
@r_cpp
CMake and c++ libraries

Hi everyone,

At work, I stumbled upon something that seems completely absurd to me, but perhaps someone here will have a different perspective.

We have a software architect who defines the data model using .idl files (a kind of simplified struct, if you're not familiar with it). These .idl files generate C++ code.

Historically, it was C++ 98 code. And now it also includes "modern" C++ code, meaning that arrays are no longer T[\] but rather vector<T>, for example. Originally, these IDL files are used within our kind-of micro services. They update the data model within the distributed monolith, and we develop related features.

Under the pretext that these are the same source IDL files, our software architect imposes and provides us with the same CMake target name for both. This means we have to generate one install folder in 98 and another in "modern" C++.

And for the software where we'd like to start mixing the two within the same CMake project, we're stuck because we're limited to a single CMake target for two final .so files.

Do any of you see the point of his approach?

Would you recommend having a unique target name for each .so/.a ?

https://redd.it/1ua0xc4
@r_cpp
libc.so and libstdc++.so

Can someone tell me whether what I'm saying is correct or not? A Linux distribution running on x86 has to include the `libc.so` and `libstdc++.so` libraries. These libraries are needed to run C and C++ programs. They must be present so that programs can communicate with the operating system. For example, if a program uses printf, does it have to use `libc.so` in order to print text to the screen in C?

https://redd.it/1ua0uf9
@r_cpp
I built a custom DX11 engine that lets you layer 70+ real-time shaders over your entire Windows desktop (Zero input lag, no game hooking)

Hey everyone,

I’ve been developing a real-time post-processing engine called Shade Elements, and it is finally live. It essentially transforms your entire Windows operating system, applications, and games into a living canvas.

The main goal was to build something insanely powerful but completely non-invasive. Instead of injecting into game files (which triggers aggressive anti-cheat software), Shade Elements uses a custom C++ DirectX 11 engine to operate entirely as a screen-space overlay. It hooks the display compositor directly, meaning you get zero input lag and zero ban risks.

Here is what the engine can do:

70+ Stackable Shaders: You aren't limited to one effect. You can stack a CRT curvature filter over a VHS tape glitch, add realistic Phosphor Burn-in, or drop an ASCII visualizer over your favorite game.
Window-Aware Technology: The engine actively reads your Z-order. You can use the Bokeh Depth of Field shader to automatically track your active foreground window, keeping it razor-sharp while blurring out your messy desktop behind it.
Temporal Memory: The pipeline utilizes history buffers, allowing for buttery-smooth Motion Blur or the ability to "Save State" a snapshot of your screen mid-render and composite it back into the pipeline later.
Live Customization: Every shader has real-time sliders (Intensity, Radius, Speed, etc.) that parse dynamically. Plus, global hotkeys let you kill the overlay instantly without tabbing out.

I would love for you to try it out and tear it apart. I’ve set it up so the first 100 downloads are completely free!

You can check it out and grab a copy here:https://compaces.itch.io/shade-elements

Let me know what you think of the tech, or if you have any requests for new shaders to add to the vault!

https://redd.it/1ua583u
@r_cpp
The problem with targeting Linux

Linux unlike MacOS and Windows doesn't have a standardised SDK. This forces devs to either natively compile there or create SDK/sysroot ourselves.

&#x200B;

This creates some issues, firstly everyone targets different sets of packages for shared linking, this causes glibc version mismatches and similar issues.

&#x200B;

In the end, why are we dealing with this, why can't Debian and Ubuntu Devs just collaborate to release a tarball for arm64 and x64 desktop. We could just download it and set the flags and everything works.

&#x200B;

But currently we have to create a sysroot via docker, weird system packages with Debian etc. None of them are really ideal.

&#x200B;

The rest of the Devs who target mini-pc's or try to run Linux on milkv-duos can build their own sysroot from scratch, while we can just move to actual work.

&#x200B;

https://redd.it/1ub4s64
@r_cpp
A tiny C++23 filesystem wrapper that returns std::expected instead of throwing

Hi everyone,

I’ve been working on a small C++23 header-only library called **expected_fs**:

https://github.com/MrZLeo/expected-fs

It’s a thin wrapper around `std::filesystem` where fallible operations return `std::expected<T, std::error_code>` instead of throwing `std::filesystem_error`.

The idea is not to replace `std::filesystem`, but to make filesystem code easier to compose in projects that prefer explicit error handling.

Example:

```cpp
#include <expected_fs/expected_fs.hpp>

#include <iostream>

int main() {
const auto size = expected_fs::file_size("data.txt");

if (!size) {
std::cerr << size.error().message() << '\n';
return 1;
}

std::cout << *size << '\n';
}
```

Most function names mirror `std::filesystem`, so usage should feel familiar:

```cpp
auto created = expected_fs::create_directories("out/cache");
auto copied = expected_fs::copy_file("input.txt", "out/input.txt");
auto removed = expected_fs::remove("out/input.txt");
```


It's simple and it just work. I’d love feedback on the API shape, naming, CMake packaging, and whether this feels useful to people who avoid exception-based filesystem handling.

Thanks for taking a look! :)

https://redd.it/1ubq20l
@r_cpp
nanobind: the bridge between C++ and Python...

nanobind is a C++17-first binding library , inspired by pybind11 but redesigned with a sharper focus on performance, compile times, and modern C++ practices. It’s built for developers who care about control—over lifetimes, memory, ABI stability, and error handling—without drowning in boilerplate.

&#x200B;

Interested?

&#x200B;

Read on

&#x200B;

https://som-itsolutions.hashnode.dev/nanobind-the-bridge-between-c-and-python

https://redd.it/1ubtu4j
@r_cpp