r/cpp • u/el_DuDeRiNo238 • Mar 24 '26
A Commonly Unaddressed Issue in C++ and Golang Comparisons
reddit.comNot the OP.
Just curious, What are your thoughts on this?
r/cpp • u/el_DuDeRiNo238 • Mar 24 '26
Not the OP.
Just curious, What are your thoughts on this?
A technical deep-dive into shipping a C++ / ImGui desktop app through Apple's review process. Code signing, static linking, sandboxing, and everything that broke along the way.
r/cpp • u/bbmario • Mar 23 '26
r/cpp • u/Low-Cook-3544 • Mar 23 '26
Going 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
CppCon
2026-03-16 - 2026-03-22
2026-03-09 - 2026-03-15
2026-03-02 - 2026-03-08
2026-02-23 - 2026-03-01
ADC
2026-03-16 - 2026-03-22
2026-03-09 - 2026-03-15
2026-03-02 - 2026-03-08
2026-02-23 - 2026-03-01
Meeting C++
2026-03-16 - 2026-03-22
2026-03-09 - 2026-03-15
2026-03-02 - 2026-03-08
2026-02-23 - 2026-03-01
C++Online
2026-03-09 - 2026-03-15
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
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
A follow-up to my recent posting in r/cpp.
r/cpp • u/Clean-Upstairs-8481 • Mar 22 '26
Being 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
The actual presentation starts around 4:40.
r/cpp • u/sporacid • Mar 21 '26
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
r/cpp • u/eisenwave • Mar 21 '26
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:
r/cpp • u/Naive_Faithlessness1 • Mar 22 '26
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
A 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
r/cpp • u/pedersenk • Mar 20 '26
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:
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
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
In 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
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.
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
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.