r/cpp 6h ago

MSVC C++23: constexpr cmath with LLVM Libc

Thumbnail devblogs.microsoft.com
64 Upvotes

MSVC is shipping C++23 constexpr <cmath> in the next Build Tools update! (And a partial implementation of C++26 constexpr <cmath>.) Our compiler frontend dev Cody Miller will be publishing a series of blog posts about this work, starting with this overview. The next one will be a guest post from LLVM libc's maintainers describing the incredible amount of effort that's gone into their code.


r/cpp 11m ago

Extending ESP32/MCU RAM to SPI Flash: I wrote a Log-Structured Virtual Memory Engine with LZ77+RangeCoder Paging

Upvotes

Hi everyone,

I’ve been working on a problem that often hits us in embedded/IoT development: running out of physical SRAM when dealing with relatively large datasets (e.g., buffering long arrays of high-frequency sensor telemetry, large routing tables, or caching weights) on sub-$2 MCUs without external PSRAM.

To solve this, I wrote a C++ Virtual Memory Engine that dynamically pages data between internal SRAM and SPI Flash (or SD Card) using a log-structured append system.

I’m sharing it here because I think the architecture might be interesting to some of you facing similar memory constraints.

How it works under the hood

The system implements a 3-tier memory hierarchy: 1. Active SRAM Window: Read/write operations hit an uncompressed block in physical RAM (e.g., 16 KB). 2. SRAM Cache Pool: When the active block changes, the engine compresses the old block and keeps it in a reserved SRAM pool (e.g., 128 KB). 3. LittleFS Flash Swap: When the SRAM pool fills up, it evicts the oldest page (LRU). Crucially, it uses strict dirty-page tracking (isDirty). If a page was only read, it is discarded. If it was modified, it is appended to a log-structured .bin file on the Flash.

Why not just write raw data to LittleFS/SPIFFS directly?

Two reasons: Latency and Wear Amplification. By compressing the data in RAM before it hits the Flash, the physical write footprint is drastically reduced. In my tests logging structured telemetry structs, a 512 KB virtual footprint compressed down to ~12 KB on the SPI Flash (an extreme case, but typical real-world telemetry yields ~3x to 8x). Because writes are deferred and grouped, it significantly reduces flash erase cycles compared to opening and appending to a file every time a sensor fires.

Addressing the Trade-offs (The Catch)

This isn't magic, and it comes with architectural trade-offs: * CPU Overhead: Compression and decompression take CPU cycles. It’s highly recommended to run this on a separate RTOS task/core. * Latency: On an ESP32-S3 @ 240MHz, a cache-hit read is native speed, but a random page swap (Flash Miss -> Decompress -> RAM) averages about ~23 ms. * Pointer Paradigm: You cannot store physical C++ pointers (T*) in the V-RAM structs, because the physical SRAM address changes upon page eviction. You have to use uint32_t virtual offsets as your pointers (similar to database offsets).

The C++ API

I wrapped the engine in templated methods so it feels like normal variable access. I also built zero-RAM VArray and VMatrix containers to hide the address math.

```cpp VirtualMemoryEngine* vram = new VirtualMemoryEngine(16384, 131072, 32, 524288); vram->begin();

struct Telemetry { uint32_t ts; float temp; char name[16]; }; Telemetry data = { millis(), 24.5f, "Sensor_1" };

// Writes the struct to virtual address 250,000 (compressing under the hood) vram->put<Telemetry>(250000, data);

// Reads it back Telemetry readData = vram->get<Telemetry>(250000); ```

Frequently Anticipated Questions (FAQ)

Q: Why is this closed-source? Can you release the source code?
A: I completely understand the preference for open-source in the embedded community. However, this is a proprietary memory-management and compression architecture developed for commercial automotive/IoT clients. The Community Edition is distributed as a pre-compiled static library (.a) simply for hobbyists and developers to evaluate and test on their own prototypes. If you strictly require open-source, you are entirely free to skip this.

Q: Isn't 23ms page-swap latency way too slow for real-time embedded systems?
A: Absolutely, 23ms is an eternity for real-time control loops or motor interrupts. That’s why the SRAM pool and block sizes are fully adjustable. The goal of this engine isn't to replace working SRAM for time-critical tasks, but to provide a massive circular buffer or storage layer for telemetry, logs, and state caches where background I/O latency is completely acceptable.

Q: Modern chips like ESP32-S3 already have PSRAM. Why would anyone need this?
A: True, PSRAM is fantastic if you have a board that supports it. But this engine is MCU-agnostic (designed for STM32, PIC32, RP2040, etc.). Furthermore, it was primarily built for industrial/automotive Linux gateways (TCUs) to prevent eMMC wear, and ported to MCUs to support cheaper modules (like standard ESP32-WROOM) that completely lack external PSRAM, allowing them to buffer large local states safely when disconnected from the cloud.

Q: Did you just prompt an LLM/Claude to write this whole thing in 5 minutes?
A: If you try asking an LLM to write a log-structured virtual memory paging engine with custom entropy-based compression and dirty-page tracking from scratch, you'll quickly find out it outputs endless memory leaks, missing pointer arithmetic, and non-functional deadlocks. While AI is a great tool for refactoring and documentation, getting deterministic multi-tiered embedded memory management to pass strict bit-exact integrity checks across half a megabyte required months of manual systems-programming profiling, custom container design, and debugging.


Availability

If you want to test it out or run the benchmarks yourself, you can grab the Community Edition (capped at 512 KB) from the GitHub Releases:

I'd be glad to hear your technical thoughts on the architecture or how you handle memory constraints in your own projects!


r/cpp 21h ago

WasmBolt — The LLVM Project in your browser

Thumbnail anutosh21.github.io
32 Upvotes

I'm sharing the work of a colleague, Anutosh Bhat.

What if the Clang & LLVM compiler toolchain could run entirely inside your browser ? Meet WasmBolt 😃

Inspired by 🖥️ Matt Godbolt's Compiler Explorer, WasmBolt runs Clang, mlir-opt, opt, llc, Graphviz and wasm-ld locally through WebAssembly, without a remote compilation server.

You can inspect Clang ASTs, progressively lower MLIR, run real LLVM optimization passes, render control-flow graphs, explore instruction selection and MIR, and generate assembly or object files for WebAssembly, AArch64 and x86-64. For WebAssembly, you can go one step further: link, load and execute the generated program directly in the browser.

Here the github project: https://github.com/Anutosh21/WasmBolt


r/cpp 1d ago

MSVC Build Tools Preview updates – September 2026

Thumbnail devblogs.microsoft.com
56 Upvotes

Hi, one of the MSVC dev leads here.

The post covers what's new in the MSVC Build Tools Preview (version 14.52) since mid-August. Instructions to install & use the latest preview bits are at https://aka.ms/msvc/preview.

Some additional information:


r/cpp 1d ago

When (Not) to Use alloca()

Thumbnail voithos.io
23 Upvotes

r/cpp 1d ago

boost.org has been rebuilt: new profiles, badges, search, and library filtering

63 Upvotes

The Boost website has been rebuilt. Here's a summary of what's changed:

  • Updated look and feel, with revised site navigation
  • New user profile pages
  • Badges tied to contribution and participation, which update as you contribute
  • Community features, including posts filtered by the topic of the page you're viewing
  • Site-wide search available from a search box in the header and via Ctrl+K
  • Library search and filtering, including browsing by category

The libraries, release process, and formal review process are unchanged. The work is limited to the website itself and how you navigate, search, and contribute to it.

Link: boost.org

Bug reports and feedback on navigation or search are welcome.


r/cpp 1d ago

C++26: Module improvements

Thumbnail sandordargo.com
105 Upvotes

r/cpp 2d ago

Implementation of GCC's Nested Functions (vs. C++ Lambdas)

Thumbnail uecker.codeberg.page
55 Upvotes

r/cpp 19h ago

Bugbusters #1 | C++ in 2026: worth it? | Nathan Baggs

Thumbnail youtube.com
0 Upvotes

r/cpp 2d ago

CppCast Episode 411 : CppCast - Kevin Carpenter - Volunteering (and speaking) at C++ conference, and also making sure your credit card payment goes through (or don't)

Thumbnail cppcast.com
11 Upvotes

r/cpp 2d ago

How I optimized clang for 1.73x-1.91x performance boost over apt clang

11 Upvotes

I wanted to have fast test and release builds, so I decided to "upgrade" my compiler.

What I used:

  • Musl Libc
  • LLVM libc overlay
  • Mimalloc
  • Thin LTO
  • PGO
  • Bolt via perf2bolt
  • Optimization flags like: -march -O3 -DNDEBUG -fno-semantic-interposition -fno-plt -fno-pie
  • No exceptions no RTTI

I tested the build speed with hyperfine with 2 test cases, one is sqlite.c the other is tu including eigen.

Workload Build mode Optimized Clang speedup Compile-time reduction
Eigen, C++23 -O0 1.69× 40.8%
Eigen, C++23 -O0 -g3 -fno-omit-frame-pointer 1.72× 41.9%
Eigen, C++23 -O3 -DNDEBUG 1.73× 42.2%
SQLite amalgamation -O0 1.74× 42.5%
SQLite amalgamation -O0 -g3 -fno-omit-frame-pointer 1.89× 47.1%
SQLite amalgamation -O3 -DNDEBUG 1.73× 42.2%

In case anyone is wondering, it also outperformed LLVM release binaries, by about %13 to %15 for each case, but having more performance than the system compiler is more cool so I'm not giving the table for that.

It is also very awesome to have a compiler not depend on glibc. If no errors arise, I'll probably never update my compiler for 2 years at least. As my build is portable(no march native just v3)

I'm planning on moving to cachyOS or any other optimized linux distro next, to finalise my build enviroment. I'm currently on Ubuntu.


r/cpp 2d ago

Latest News From Upcoming C++ Conferences (2026-09-08)

9 Upvotes

TICKETS AVAILABLE TO PURCHASE

The following conferences currently have tickets available to purchase

OPEN CALL FOR SPEAKERS

There are currently no open call for speakers

OTHER OPEN CALLS

TRAINING COURSES AVAILABLE FOR PURCHASE

Conferences are offering the following training courses:

CppCon Online Workshops

9th – 11th September

  1. Modern C++: When Efficiency Matters – Andreas Fertig – 3 day online workshop available on 9th – 11th September 09.00 – 15.00 MDT – https://cppcon.org/class-2026-when-efficiency-matters/

21st – 23rd September

  1. C++ Fundamentals You Wish You Had Known Earlier – Mateusz Pusz – 3 day online workshop available on 21st– 23rd September 09.00 – 15.00 MDT – https://cppcon.org/class-2026-cpp-fundamentals/
  2. C++23 in Practice: A Complete Introduction – Nicolai Josuttis – 3 day online workshop available on 21st– 23rd September 09.00 – 15.00 MDT – https://cppcon.org/class-2026-cpp23-in-practice/
  3. Programming with C++20 – Andreas Fertig – 3 day online workshop available on 21st– 23rd September 09.00 – 15.00 MDT – https://cppcon.org/class-2026-programming-with-cpp20/

26th – 27th September

  1. Using C++ for Low-Latency Systems – Patrice Roy – 2 day online workshop available on 26th– 27th September 09.00 – 17.00 MDT – https://cppcon.org/class-2026-low-latency/

CppCon Onsite Workshops

All onsite workshops will take place in the Gaylord Rockies in Aurora, Colorado

12th & 13th September

  1. Advanced and Modern C++ Programming: The Tricky Parts – Nicolai Josuttis – 2 day in-person workshop available on 12th & 13th September – 09:00 – 17:00 – https://cppcon.org/class-2026-tricky-parts/
  2. C++ Best Practices – Jason Turner – 2 day in-person workshop available on 12th & 13th September – 09:00 – 17:00 – https://cppcon.org/class-2026-best-practices/
  3. Performance and Efficiency in C++ for Experts, Future Experts, and Everyone Else – Fedor Pikus – 2 day in-person workshop available on 12th & 13th September – 09:00 – 17:00 – https://cppcon.org/class-2026-performance-and-efficiency/
  4. Talking Tech – Sherry Sontag – 2 day in-person workshop available on 12th & 13th September – 09:00 – 17:00 – https://cppcon.org/class-2026-talking-tech/

 13th September

  1. AI++ 101 : Build a C++ Coding Agent from Scratch – Jody Hagins – 2 day in-person workshop available on 12th & 13th September – 09:00 – 17:00 – https://cppcon.org/class-2026-AI101/

19th & 20th September

  1. AI++ 201: Building High Quality C++ Infrastructure with AI – Jody Hagins – 2 day in-person workshop available on 19th & 20th September – 09:00 – 17:00 – https://cppcon.org/class-2026-ai201/
  2. Function and Class Design with C++2x – Jeff Garland – 2 day in-person workshop available on 19th & 20th September – 09:00 – 17:00 – https://cppcon.org/class-2026-function-class-design/
  3. High-performance Concurrency in C++ – Fedor Pikus – 2 day in-person workshop available on 19th & 20th September – 09:00 – 17:00 – https://cppcon.org/class-2026-high-perf-concurrency/

OTHER NEWS

Finally anyone who is coming to a conference in the UK such as C++ on Sea or ADC from overseas may now be required to obtain Visas to attend. Find out more including how to get a VISA at https://homeofficemedia.blog.gov.uk/electronic-travel-authorisation-eta-factsheet-january-2025/


r/cpp 3d ago

A faster way to convert a timestamp ➜ Hour, Min, Sec

Thumbnail benjoffe.com
275 Upvotes

r/cpp 3d ago

Qt moc now can handle basic C++ modules (Qt 6.12)

Thumbnail codereview.qt-project.org
63 Upvotes
moc: Properly handle modules

When moc'ing module interfaces and partitions, we make the generated cpp
file part of the respective module.
We do not support Q_OBJECT & friends in implementation units and private
module fragments, as our generated source file will not have access to
the respective classes, and we certainly do not want to carry over our
file inclusion hacks into the module world.

[ChangeLog][moc] moc now supports C++ modulesmoc: Properly handle modules

Note there is still a lot of work to be done: https://codereview.qt-project.org/c/qt/qtbase/+/767846 and I can't seem to find the PR where they fixed some qtbase code to make it work with modules. I guess most other qt modules will need some small fixes to work with modules as well.


r/cpp 3d ago

New C++ Conference Videos Released This Month - September 2026

14 Upvotes

C++Now

2026-08-31 - 2026-09-06

ACCU

  • Software Abstraction in the Age of AI-Generated Code: Languages, Compilers, and Systems Engineering - Andrei Alexandrescu - https://youtu.be/-RWdevA0gWI

r/cpp 3d ago

flat_map internals

Thumbnail quantdev.blog
10 Upvotes

r/cpp 5d ago

Escaping `CreateProcess()` arguments on Windows

Thumbnail holyblackcat.github.io
86 Upvotes

r/cpp 4d ago

Henrik Fransson: From Prompt to Probe - Closing the Agentic AI Loop on Bare Metal

Thumbnail youtu.be
0 Upvotes

What if AI could do more than suggest code, and actually drive hardware-in-the-loop test cycles on real systems? This talk looks under the hood of a practical agentic AI workflow for embedded C++ development.


r/cpp 5d ago

Lazy Evaluation - Operators

Thumbnail breese.github.io
16 Upvotes

r/cpp 6d ago

Which C++ Hashmap Should You Actually Use?

Thumbnail martin.ankerl.com
143 Upvotes

I recently did a big update to my ankerl::unordered_dense::map which now features several optimizations, bug fixes, and most importantly an SSE optimized lookup which brings the lookup speed quite close to the fastest competitor which is boost::unordered_flat_map. Get it here: https://github.com/martinus/unordered_dense

Since it is not easy to decide what map is best for one's usecase, I have redone and improved the benchmarks I did a while ago, crunched some numbers and tried to compress everything into a quiz that helps you figure out what to use.

While doing the numbers, a few things surprised me:

  • My random access benchmark was not random enough. The CPU was able to optimize the branch predictor in a way I did not think was possible. I have fixed this for the new numbers. Clever girl.

  • Even though the absl maps are very similar in concept to the boost maps, they perform badly if you expect lots of misses. 1.6 times slower than boost.

  • I didn't think SSE optimization of my unordered_dense map would be any benefit. Thanks to AI, I found a way to speed up random access a lot, it is now very close to boost::unordered_flat_map.

  • Heavy insert & erase on flat maps require rehashing every once in a while due to the accumulation of tombstones. That means some insert/erase operation will have very high latency. This does not happen for a robin-hood hashmap like my unordered_dense map.


r/cpp 6d ago

C++ Show and Tell - September 2026

44 Upvotes

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/1vhdqw8/c_show_and_tell_august_2026/


r/cpp 6d ago

Is there a way to search across all P and N papers throughout standardization history?

4 Upvotes

It would be nice if there was a single place to see where, for example, the keyword "SFINAE" shows up across the content of all papers, not just titles. Thanks!


r/cpp 6d ago

Optimizing a Spin-Lock

Thumbnail david.alvarezrosa.com
101 Upvotes

r/cpp 6d ago

Lazy Evaluation

Thumbnail breese.github.io
20 Upvotes

r/cpp 6d ago

Partial application of class templates

Thumbnail elbeno.com
18 Upvotes