r/cpp • u/bbmario • Mar 23 '26
r/cpp • u/Low-Cook-3544 • Mar 23 '26
Porting retro C++ games to browser with Emscripten
lab.rosebud.aiGoing into it, I expected the hard part to be the C++ itself, tracking down undefined behavior, linker errors, and the usual cross-platform issues.
That turned out not to be the case.
Almost all of the work ended up in the build system and the dependency graph.
Before touching Wesnoth’s code, we had to get its dependencies compiling to WebAssembly. Wesnoth uses vcpkg, which provides portfiles for things like glib, cairo, pango, freetype, brotli, and zlib. Those portfiles assume a native target. They don’t know what to do with emcc.
The approach that worked was using vcpkg overlay ports: a parallel set of recipes overriding the upstream ones specifically for Emscripten. Each dependency needed some amount of surgery.
glib probes for POSIX thread resolver APIs that don’t exist in the browser and will happily hang if they’re missing. pango calls into fontconfig synchronously during initialization, which doesn’t map cleanly onto WASM’s async model, so we added a synchronous shim. A number of libraries unconditionally link against Threads::Threads, which injects -pthread and breaks under JSPI, so we replaced that with a no-op target so the build could proceed.
Across roughly ten libraries, this came out to around sixty portfiles and patches. None of that work shows up in the application code. The C++ itself is relatively thin here but the build infrastructure is not.
Once everything compiled, the next problem was configuration. Emscripten exposes a large number of flags like threading model, async behavior, filesystem backend, audio routing, and there isn’t a canonical answer for a codebase like this. It ends up being a search problem. Try a configuration, build, run, see what breaks.
The most frustrating issue showed up at runtime as random browser freezes. The tab would lock up without crashing or logging anything useful. The cause turned out to be long-running WASM frames that never yielded back to JavaScript, effectively starving the event loop. On desktop you get preemption for free; in the browser you don’t.
The fix was a single call to emscripten_sleep(0) at the top of the main loop. Not a real sleep, just a yield.
What actually changed in the codebase was much smaller than I expected. Out of roughly a million lines of C++, four source files handle all browser-specific I/O. Everything else compiled unchanged.
The takeaway for me was that porting something like this is less about adapting the application code and more about unwinding assumptions in the ecosystem around it. Hope to answer any questions or show you the final game if anyone found this useful.
r/cpp • u/ProgrammingArchive • Mar 23 '26
New C++ Conference Videos Released This Month - March 2026 (Updated To Include Videos Released 2026-03-16 - 2026-03-22)
CppCon
2026-03-16 - 2026-03-22
- Building a C++ Career Off-Road - Sherry Sontag - https://youtu.be/SNZlxHDrwM4
- The Pattern Matching We Already Have - Braden Ganetsky - https://youtu.be/zB6ORpZjneQ
- Upgrading Sea of Thieves From C++14 to C++20 Wasn't Easy Here's Why - Keith Stockdale - https://youtu.be/b6j6SZiXmoo
- Can Standard C++ Replace CUDA for GPU Acceleration? - Elmar Westphal - https://youtu.be/EOvukoCyW7A
2026-03-09 - 2026-03-15
- Cache Me Maybe: The Performance Secret Every C++ Developer Needs - Michelle D'Souza - https://youtu.be/VhKq0nzPTh0
- It’s Dangerous to Go Alone: A Game Developer Tutorial - Michael Price - https://youtu.be/TIXf24aUmA0
- Seamless Static Analysis with Cppcheck: From IDE to CI and Code Review - Daniel Marjamäki - https://youtu.be/7u97LZYxu3g
- Knockin' on Header's Door: An Overview of C++ Modules - Alexsandro Thomas - https://youtu.be/fZrDG_he9sE
- Modern C++ for Embedded Systems: From Fundamentals to Real-Time Solutions - Rutvij Girish Karkhanis - https://youtu.be/7uwPcCfcv1k
2026-03-02 - 2026-03-08
- Interesting Upcoming Low-Latency, Concurrency, and Parallelism Features from Wroclaw 2024, Hagenberg 2025, and Sofia 2025 - Paul E. McKenney, Maged Michael, Michael Wong - CppCon 2025 - https://youtu.be/M1pqI1B9Zjs
- Threads vs Coroutines — Why C++ Has Two Concurrency Models - Conor Spilsbury - CppCon 2025 - https://youtu.be/txffplpsSzg
- From Pure ISO C++20 To Compute Shaders - Koen Samyn - CppCon 2025 - https://youtu.be/hdzhhqvYExE
- Wait is it POSIX? Investigating Different OS and Library Implementations for Networking - Katherine Rocha - CppCon 2025 - https://youtu.be/wDyssd8V_6w
- End-to-End Latency Metrics From Distributed Trace - Kusha Maharshi - CppCon 2025 - https://youtu.be/0bPqGN5J7f0
2026-02-23 - 2026-03-01
- Fix C++ Stack Corruptions with the Shadow Stack Library - Bartosz Moczulski - CppCon 2025 - https://youtu.be/-Qg0GaONwPE
- First Principles While Designing C++ Applications - Prabhu Missier - CppCon 2025 - https://youtu.be/8mLo5gXwn4k
- Matrix Multiplication Deep Dive || Cache Blocking, SIMD & Parallelization - Aliaksei Sala - CppCon 2025 - https://youtu.be/GHctcSBd6Z4
- Choose the Right C++ Parallelism Tool | Low-Level vs Async vs Coroutines vs Data Parallel - Eran Gilad - CppCon 2025 - https://youtu.be/7a9AP4rD08M
- ISO C++ Standards Committee Panel Discussion 2025 - Hosted by Herb Sutter - CppCon 2025 - https://youtu.be/R2ulYtpV_rs
ADC
2026-03-16 - 2026-03-22
- Web UIs for Music Apps - Anna Wszeborowska, Harriet Drury, Emma Fitzmaurice, Pauline Nemchak & Simeon Joseph - https://youtu.be/xh-yJpuWYSo
- Python Templates for Neural Image Classification and Spectral Audio Processing - Lightning Hydra Template Extended and Neural Spectral Modeling Template - Julius Smith - https://youtu.be/TNY2UGQ5kAc
- Why You Can’t Get Hired and What You’re Going To Do About It - The Hard Reset for Audio Freelancing - Edward Ray - https://youtu.be/4TjR3i6M93Y
2026-03-09 - 2026-03-15
- Engineering Practices Break Music Interaction - (but Can Also Fix It) - Franco Caspe - https://youtu.be/aGYPFjibwaY
- Python Templates for Neural Image Classification and Spectral Audio Processing - Lightning Hydra Template Extended - Julius Smith - https://youtu.be/vH21UqZafa4
- Making a 3D DAW in Unity: Chaos, Logic, and Physics - Noah Feasey-Kemp - https://youtu.be/6WeecBwyEyM
2026-03-02 - 2026-03-08
- Efficient Task Scheduling in a Multithreaded Audio Engine - Algorithms and Analysis for Parallel Graph Execution - Rachel Susser - ADC 2025 - https://youtu.be/bEtSeGr8UvY
- The Immersive Score - Creative Advantages of Beds and Objects in Film and Game Music - Simon Ratcliffe - ADCx Gather 2025 - https://youtu.be/aTmkr0yTF5g
- Tabla to Drumset - Translating Rhythmic Language through Machine Learning - Shreya Gupta - ADC 2025 - https://youtu.be/g14gESreUGY
2026-02-23 - 2026-03-01
- Channel Agnosticism in MetaSounds - Simplifying Audio Formats for Reusable Graph Topologies - Aaron McLeran - ADC 2025 - https://youtu.be/CbjNjDAmKA0
- Sound Over Boilerplate - Accessible Plug-Ins Development With Phausto and Cmajor - Domenico Cipriani - ADCx Gather 2025 - https://youtu.be/DVMmKmj1ROI
- Roland Future Design Lab x Neutone: diy:NEXT - Paul McCabe, Ichiro Yazawa & Alfie Bradic - ADC 2025 - https://youtu.be/4JIiYqjq3cA
Meeting C++
2026-03-16 - 2026-03-22
- How to understand modern C++ features in practice? Let's create a compiler! - Boguslaw Cyganek - https://www.youtube.com/watch?v=_uuUw8N0qQ0
2026-03-09 - 2026-03-15
- Building Bridges: C++ Interop, Foreign Function Interfaces & ABI - Gareth Williamson - https://www.youtube.com/watch?v=0X_qgWQdvrg
- "But my tests passed!" - Exploring C++ Test Suite Weaknesses with Mutation Testing - Nico Eichhorn - https://www.youtube.com/watch?v=G_TDxhZB4t8
2026-03-02 - 2026-03-08
- Binary compatibility 100 - Marc Mutz - https://www.youtube.com/watch?v=mPtjFsje1eo
- Persistence squared: persisting persistent data structures - Juan Pedro Bolívar Puente - Meeting C++ - https://www.youtube.com/watch?v=pQhHx0h-904
2026-02-23 - 2026-03-01
- Instruction Level Parallelism and Software Performance - Ivica Bogosavljevic - Meeting C++ 2025 - https://www.youtube.com/watch?v=PMu7QNctEGk
- Real-time Safety — Guaranteed by the Compiler! - Anders Schau Knatten Meeting C++ 2025 - https://www.youtube.com/watch?v=4aALnxHt9bU
C++Online
2026-03-09 - 2026-03-15
- From Hello World to Real World - A Hands-On C++ Journey from Beginner to Advanced - Workshop Preview - Amir Kirsh - https://youtu.be/2zhW-tL2UXs
- Workshop Preview: C++ Software Design - Klaus Iglberger - https://youtu.be/VVQN-fkwqlA
- Workshop Preview: Essential GDB and Linux System Tools - Mike Shah - https://youtu.be/ocaceZWKm_k
- Workshop Preview: Performance and Safety in C++ Crash Course - Jason Turner - https://youtube.com/live/Ipr6ntCAm9A
- Workshop Preview: Concurrency Tools in the C++ Standard Library - A Hands-On Workshop - Mateusz Pusz - https://youtube.com/live/Kx9Ir1HBbwY
- Workshop Preview: Mastering std::execution (Senders/Receivers) - A Hands-On Workshop - Mateusz Pusz - https://youtube.com/live/bsyqh_bjyE4
- Workshop Preview: How C++ Actually Works - Hands-On With Compilation, Memory, and Runtime - Assaf Tzur-El - https://youtube.com/live/L0SSRRnbJnU
- Workshop Preview: Jumpstart to C++ in Audio - Learn Audio Programming & Create Your Own Music Plugin/App with the JUCE C++ Framework - Jan Wilczek - https://youtube.com/live/M3wJN0x8cJw
- Workshop Preview: AI++ 101 - Build an AI Coding Assistant in C++ & AI++ 201 - Build a Matching Engine with Claude Code - Jody Hagins - https://youtube.com/live/Vx7UA9wT7Qc
- Workshop Preview: Stop Thinking Like a Junior - The Soft Skills That Make You Senior - Sandor DARGO - https://youtube.com/live/nvlU5ETuVSY
- Workshop Preview: Splice & Dice - A Field Guide to C++26 Static Reflection - Koen Samyn - https://youtube.com/live/9bSsekhoYho
Proposal: distinct types via 'enum struct'
Currently 'enum struct' and 'enum class' have the same meaning.
My idea is that 'enum struct' should act as a scoped enumeration with the properties/interface of the underlying type.
In other words, an 'enum struct Enum : Type' defines a type 'Enum' distinct from 'Type' but which behaves as 'Type'.
While you can already kind of achieve this by using operator overloading (For example, the standard library does this with std::byte, which is an enum class), it's not ideal as it's very boilerplate heavy and non-zero cost during debugging.
Leaving many to just botch this feature by using a struct and putting an unscoped enum inside it.
Examples:
enum <none>|struct|class Enum : int { VALUE };
void unscoped_test() {
VALUE; // Ok if <none>, error if 'struct' or 'class' because those are scoped.
}
void scoped_test() {
Enum::VALUE; // Ok in all three cases
using enum Enum; // C++20 feature btw.
VALUE; // Ok in all three cases
}
void add_enums_test() {
Enum::VALUE + Enum::VALUE; // Ok if <none> or 'struct' (under this proposal), error if 'class' (no operator+ defined for enum) or 'struct' (without this proposal).
}
void operation_with_underlying_type_test() {
Enum::VALUE + 1; // Ok if <none>, error if 'class' or 'struct' (both under this proposal and without)
}
Enum operator+(Enum lhs, Enum rhs) { return Enum((int)lhs + (int)rhs); }
void overloaded_enum_test() {
Enum::VALUE + Enum::VALUE; // Ok for all three cases, the 'struct' case calls operator+ declared above (both under this proposal and without).
}This proposal shouldn't break existing code, as it makes previously ill-formed code valid... but there's probably something I missed. Also, from my experience, 'enum struct' is seldom used.
r/cpp • u/_malfeasance_ • Mar 23 '26
a vcpkg browser written in c++
this vcpkg browser itched a scratch - it is running on a box next to my desktop at home so don't share it too widely ;-)
the interface is a bit dodgy but it fulfills my basic curiosity. i was mainly interested in looking at new packages (last month check box), sorting by last update, getting readme summaries (done with an llm offline), looking at repo versions vs vcpkg versions. written in c++ and imgui fwiw.
the similar packages info is a bit dodgy. you're better off using the search. it's a desktop app layout. it won't work on your phone unless your phone is a bit unusual.
r/cpp • u/tartaruga232 • Mar 23 '26
Using MSVC's C++ Module Partitions
abuehl.github.ioA follow-up to my recent posting in r/cpp.
r/cpp • u/Clean-Upstairs-8481 • Mar 22 '26
C++20 Ranges vs traditional loops: when to use std::views instead of raw loops
techfortalk.co.ukBeing an embedded software engineer I have to often work with various different types of sensor data and then process those in different ways with complex logic. I have used traditional loops for years until I came across an interesting feature of C++20. I cannot use the deal data but to demostrate here. So cooked up some fake data to make the point.
r/cpp • u/pavel_v • Mar 22 '26
Contract Assertions Against Security, Functional Safety and Correctness - Andrzej Krzemieński
youtube.comThe actual presentation starts around 4:40.
r/cpp • u/sporacid • Mar 21 '26
Slot map implementation for C++20
I've just finished submitting the initial version of my slot map implementation, based on this post. A slot map is a data structure that provides stable and versioned keys to stored values. Inserting into the map creates and return a unique key, which stays valid until the slot is explicitly freed.
I hope someone will find this useful :)
https://github.com/sporacid/slot-map
EDIT: As suggested by some of you, I've added benchmarks to compare to plf::colony. As i did those benchmarks, I had to work on a bunch of optomizations to compete, and I've introduce a static storage that has a fixed number of slots, and I kept the original dynamic storage with a fixed number of blocks, but the blcoks are allocated as needed. Let me know what you think!
r/cpp • u/meetingcpp • Mar 21 '26
Meeting C++ How to understand modern C++ features in practice? Let's create a compiler! - Boguslaw Cyganek - Meeting C++ 2025
youtube.comr/cpp • u/eisenwave • Mar 21 '26
Last C++26 meeting in Croydon is about to begin
Since not everyone is aware and confusion often arises regarding privated GitHub repos, let's inform people on Reddit this time: The last meeting for C++26 is about to begin. Some quick facts:
- The meeting lasts from 2026-03-23 (Mon morning) to 2026-03-28 (Sat afternoon). See also https://isocpp.org/std/meetings-and-participation/upcoming-meetings
- Until the meeting ends, https://github.com/cplusplus/papers/ is private. The repos usually become visible again immediately after the meeting ends.
- The papers published during and after the meeting all go into the April mailing 2026-04-20. This includes the final working draft.
- All remaining NB (national body) comments should be resolved during this meeting. The working draft is then sent off to ISO for review and national bodies vote on the C++26 standard as a whole (yes/no/abstain).
- Any C++26 work takes priority, but once that is completed, time is spent on C++29 papers.
r/cpp • u/Naive_Faithlessness1 • Mar 22 '26
namespace dependent lookup ?
Hi !
I'm kind of deceived that it does not work like this. Here's some code:
int
Here's the compiler output:
<source>:9:28: error: 'apple' was not declared in this scope; did you mean 'me::fruit::apple'?
9 | auto l = me::fruit::lychee(apple{}, pear{});
| ^~~~~
| me::fruit::apple
<source>:2:12: note: 'me::fruit::apple' declared here
2 | struct apple { /*...*/ };
| ^~~~~
<source>:9:37: error: 'pear' was not declared in this scope; did you mean 'me::fruit::pear'?
9 | auto l = me::fruit::lychee(apple{}, pear{});
| ^~~~
| me::fruit::pear
<source>:3:12: note: 'me::fruit::pear' declared here
3 | struct pear { /*...*/ };
As you can see the compiler is perfectly able to deduce what I mean by apple and pear but still, it doesn't compile !
I'm surprised that there still no rule in the C++ Standard to handle this kind of situation ; it seems so obvious to me that it should work this way.
I know that I could write :
int
Believe it or not, I find this code less than clear. It seems clear here because it's an example and like all examples, it's simple, but in a real-world situation, this code will undoubtedly be surrounded by other lines of code, meaning that this using directive could lead to the problems we all know.
To me this syntax remains much clearer :
int
Are we therefore condemned to have to write :
auto l = ;
There may be solutions I'm not aware of; if so, please let me know!
Thanks !
r/cpp • u/bretbrownjr • Mar 21 '26
Common Package Specification is Out the Gate
kitware.comKristian Ivarsson: Casual, an open-source SOA platform
youtu.beA modern distributed application server for building large-scale systems with minimal configuration, written in C++. A project that definitely deserves more attention.
https://github.com/casualcore/casual
r/cpp • u/mropert • Mar 20 '26
Looking at Unity finally made me understand the point of C++ coroutines · Mathieu Ropert
mropert.github.ior/cpp • u/pedersenk • Mar 20 '26
C++/sys - A Standard Library Projection to Facilitate the Verification of Run-time Memory Safety
Hi all,
A while ago I was looking for a relevant C++ conference to demonstrate the capabilities of C++/sys. A pure C++ mechanism which offers a new approach to memory safety via debug-time verification.
My talk was accepted into C++Online 2026 which concluded a couple of weeks ago. The discussions were great, I received some really useful feedback (and the little 2D gather town was pretty fun!).
The slides are available here and the release video should appear on YouTube in the following weeks.
Excited to share the tech with the wider community. Much of it is discussed in the slides; some highlights:
- Offers improvements over AddressSanitizer in terms of C++ error detection rate
- Tracks access lifespan rather than blocks of data
- Has contextual knowledge of C++ objects and containers so generally quite performant
- 100% detection rate for executed paths
- Memory pinning and locking mechanism tracks dangling 'this' and references
- Zero overhead in release builds
- Compatible with any standard C++ compiler (from hosted C++98 running on MS-DOS to freestanding C++${LATEST} on Zephyr)
- Doesn't interfere with C code/libraries. Just like Java, Rust, Python thin-bindings, these are treated as unchecked.
Some of the above sounds like magic but the core mechanism allowing for this is quite simple. Temporaries created by operator->, operator* and operator[] lock memory for the lifetime of access and pointers are entirely prevented from dangling in a coarse-grained manner. Obviously this has an impact on what designs are possible with some discussion in the slides.
Link to the open-source (BSD 3-clause) reference implementation is here.
https://codeberg.org/kpedersen/sys_public
https://research.thamessoftware.co.uk/sys
Very happy to discuss further. It has some rough areas but I personally love the tech and find it makes writing and testing C++ considerably more satisfying knowing that there is virtually zero chance of a memory error lurking in the tested branches.
Update: Video of the talk is now released and available here.
r/cpp • u/RefrigeratorFirm7646 • Mar 20 '26
How do you reduce branch mispredictions?
I was looking into it recently and realized how many algorithms work together in order to predict branches, so I was wondering how performance engineers even figure out what will make a certain branch more predictable
r/cpp • u/emilios_tassios • Mar 20 '26
Parallel C++ for Scientific Applications: Distributed Parallelism with HPX (1st Part)
youtube.comIn this week’s lecture, Dr. Hartmut Kaiser introduces distributed parallelism using the HPX framework. The lecture highlights essential foundational concepts by discussing both the Single Program Multiple Data (SPMD) and Communicating Sequential Processes (CSP) models, establishing a strong theoretical background for distributed computing architectures.
A core discussion centers on practical implementation using HPX, demonstrating both point-to-point and collective communication examples. Finally, data partitioning, serialization, and the use of communicators within the framework are explored, offering a comprehensive approach to managing complex, high-performance distributed environments.
If you want to keep up with more news from the Stellar group and watch the lectures of Parallel C++ for Scientific Applications and these tutorials a week earlier please follow our page on LinkedIn https://www.linkedin.com/company/ste-ar-group/
Also, you can find our GitHub page below:
https://github.com/STEllAR-GROUP/hpx
r/cpp • u/germandiago • Mar 19 '26
Modern declarative EDSL for graphic user interface in C++? Not QML or XAML.
Hello everyone,
I have been investigating lately (after using NiceGUI for a real project) and learning Jetpack Compose (not writing any real code with it, would do it with Jetpack Multiplatform if ever).
I am really impressed by Jetpack Compose approach, especially UDF.
I thought there could possibly not be a better way than MVVM tbh, after using it for years.
But after seeing how declarative composition inside the language, not with XAML or QML can be done, I am sold in the amount of boilerplate that can be saved, plus the better integration when the dsl is in the host language.
So I wanted to mention I found this, which I think could be a good start for some experiments, on top of wxWidgets: https://github.com/rmpowell77/wxUI
I think it has a talk in CppCon2025 here: https://www.youtube.com/watch?v=xu4pI72zlO4
Kudos to the author for bringing something like this to C++! Definitely useful.
I would like to hear your opinions on this style of EDSL GUI embedding and pros/cons you find for those of you who do GUI programming all the time.
Also, wild idea: with the power of compile-time C++ programming and C++26 reflection, it would be possible to get existing xaml interfaces and convert it into regular C++ at compile-time via #embed or #include and not even changing the EDSL itself and making it directly embedded and reusable in C++? That would be plenty useful.
Draft idea: constructor member designators
I’ve been experimenting with a small idea to make constructor initializer lists a bit clearer and less error‑prone. The idea actually came from a dilemma I had when trying to settle on naming conventions for member variables. Prefixes like m_ or _name help avoid shadowing, but they also feel like a workaround for something the language could express more directly.
I wrote a short draft exploring “constructor member designators” - a `.member` syntax for constructor initialization.
https://github.com/richardcervinka/cpp-constructor-member-designators
This is just an experiment, but maybe someone will find it interesting.
r/cpp • u/ConsumeUranuim • Mar 18 '26
splice: a C++26 reflection-based hook and signal library
I’ve been experimenting with static reflection in the gcc16 trunk. I’ve built a library that lets you annotate class/struct methods and inject behavior through attributes.
You mark methods as hookable with [[=splice::hook::hookable{}]], then you can inject before/after/return hooks at runtime through a registry. You can cancel calls, override return values, rewrite arguments and control execution order by changing the priority of your hooks, all without touching the original class.
It also has a wire system for signal/slot connections. Slots declare which signal they handle via reflection attributes, and you can connect specific, or all signals on a listener. Listeners can also be paused, resumed, and they automatically disconnect when destroyed via RAII. If you want to wire a listener to for example, an on_click method on a class, you just add an attribute: [[SPLICE_WIRE_SLOT(.signal = ^^MyClass::on_click)]]
This currently requires GCC 16 (built from a snapshot) and the -freflection compiler flag. Still early, but all the tests pass and the API feels simple to use. Eventually, I want to use the same reflection machinery to generate FFI bindings for Lua, and maybe other scripting languages too.
GitHub: https://github.com/FloofyPlasma/splice
Curious if anyone else is experimenting with the reflection coming in C++ 26.
r/cpp • u/Ecstatic_Horror_4058 • Mar 18 '26
CppCon CppCon 2025 More Speed & Simplicity: Practical Data-Oriented Design in C++ -- Vittorio Romeo
isocpp.orgC++26: Span improvements and freestanding.
Given the freestanding remarks at https://www.sandordargo.com/blog/2026/03/18/cpp26-span-improvements blog post.
As freestanding environments generally cannot support exceptions, parts of these facilities cannot be included. Specifically, span::at() (since it throws std::out_of_range) and all overloads of std::expected::value() are excluded from the freestanding subset.
It appears that once again, even with C++26 hardening runtime, there were some security improvements that were left out of the table when targeting freestanding environments.
Like possibly having some try_at() that would return std::optional or std::expected result types.
At least looking at the proposed std::span I am not able to find such alternatives.