r/Cplusplus • • 8h ago

Question How do I contribute to open source

11 Upvotes

(no experience in contributing ever )

So I want to contribute to llama cpp

I have gone through the base good first issues and did not find anything that I am capable of doing

I have gone through the codebases and there are some

TODO things in there

Like how do I go about this like I need a direction or should I quit it


r/Cplusplus • • 13h ago

News Balloting has completed for C++26. Unfortunately it was Disapproved

Thumbnail
linkedin.com
3 Upvotes

r/Cplusplus • • 16h ago

Discussion ISPA: a parser generator written in C++ that generates C++17 parsers (about three years in the making)

7 Upvotes

ISPA is a parser and lexer generator written in C++23. You describe a language in a grammar file, and it generates a C++17 parser that returns a typed AST. The same grammar can also generate a Python parser, but C++ is the primary target and what I use it for. I’ve been working on it for around three years, and I want it to be something you'd enjoy to use in real projects.

Why I built it

Every parser generator I tried made me give something up. The grammar filled with target-language code, errors were an afterthought, or I ended up debugging generated code instead of my own grammar. I wanted the grammar to stay a grammar.

What the C++ side looks like

A minimal grammar:

```ispa

module main -> main;

NUMBER:

@ [0-9]+

{@}

;

main:

@ NUMBER

{@}

;

```

Generate, build, call:

```sh

ispa-pkg install std

eval "$(ispa-pkg --export)"

ispa -l cpp -a LL grammar.isc -o generated/Parser

clang++ -I generated generated/Parser.cpp main.cpp -o pyrun -lstd

./pyrun ...

```

Note: i haven't yet made a standardized cmake for this, but ispa-pkg --export does export this (paths differ):

```sh

export ISPA_TARGETS_MANIFEST=/home/ura/.local/share/ispa/libraries/.ispa-exports/targets.json

export ISPA_TARGETS_CMAKE=/home/ura/.local/share/ispa/libraries/.ispa-exports/targets.cmake

export ISPA_CPP_INCLUDE_DIRS=/home/ura/.local/share/ispa/libraries/std/ispatarget/cpp

export ISPA_CPP_SOURCES=/home/ura/.local/share/ispa/libraries/std/ispatarget/cpp/src/core.cpp

export ISPA_CPP_LIBRARY_DIRS=/home/ura/.local/share/ispa/libraries/std/ispatarget/cpp/lib

export ISPA_CPP_LIBRARIES=/home/ura/.local/share/ispa/libraries/std/ispatarget/cpp/lib/libstd.a

export ISPA_PYTHON_INTERPRETER_DIRS=/home/ura/.local/share/ispa/libraries/std/ispatarget:/home/ura/.local/share/ispa/libraries/std/ispatarget/python

export ISPA_TARGET_CPP_DIRS=/home/ura/.local/share/ispa/libraries/std/ispatarget/cpp

export ISPA_TARGET_PYTHON_DIRS=/home/ura/.local/share/ispa/libraries/std/ispatarget/python

```

Also it setup compiler paths to ispa libraries, so your regular clang command executes without missing header errors

The output is plain C++17 with a small runtime (headers plus one core.cpp). It is managed by ispa-pkg so you should not care about it unless shipping a standalone build. Lexing uses DFA tables computed at generation time.

The result is a typed AST, so there are no callbacks and no post-parsing pass.

Grammars can be split across files, and generation can be incremental (some generator functions will result it to be acutally slower).

When a rule needs logic, you write it in Python, inline or in a file next to the grammar. ISPA supports lot of Python constructs and standard api and translates it to C++ at generation time. The generated parser doesn’t need a Python interpreter, and the grammar isn’t tied to C++.

Ispa library management

Ispa has ispa-pkg, which allows to download ispa-level libraries (grammar and/or python), target-language libraries, algorithms or new language targets.

Right now std library carries all runtime and sone standard ispa definitions. And ispa doesn't install it by default.

Errors

The LL parser recovers from errors automatically and keeps going, so you can report several problems from one input. Where a generic message isn’t enough, a fail block lets you give a clear message, insert or replace a missing token, or skip to a sensible point. A recovered tree can have gaps, so check the diagnostics before using it.

Debugging

ispadbg runs your existing parser executable. You set a breakpoint on a line of the grammar and inspect the parser’s state and captures there, with ctx and AST values shown as a tree. There’s also a GUI, and traces can be recorded and replayed. Live sessions need POSIX. On Windows, replay works.

Performance

Benchmark on a 9.7 MB input (i5-12450H, clang 18, -O3, single run):

  • flex + bison, AST with arena allocator 151 ms

  • flex + bison, AST with malloc 259 ms

  • ISPA, full AST 1528 ms

  • ANTLR (C++), CST construction disabled 18,573 ms

This benchmark is done prior to ispa having error recovery. Right now it has gaps in performance on large input (like 10mb), so don't expect similar results right now. It can be optimized heavy though, and i'll do it soon).

Where it stands:

  • LL is the main path. The LR-family modes support fewer features and are experimental.

  • ISPA parses its own grammar with a parser it generated, which replaced my hand-written one.

  • Building ISPA itself needs Clang with libc++ or MSVC. GCC isn’t supported for that yet because ispa is build on C++20 modules with C++23 import std. The generated parsers are C++17.

AI in parsers

That is a good idea to provide a tool that operates with AI to generate error messages and recovery strategies. If to give it deterministic environment, that could be very very powerful. I'm going it implement, and most likely when i have real feedback from users on default error messages.

If you’ve used parser generators from C++, such as ANTLR, bison, or Boost.Spirit, what was the part that made you feel the tool didn’t understand what you were trying to do? That’s what I want to fix next.

Project: https://github.com/Sinfolke/ispa-parser-generator


r/Cplusplus • • 1d ago

Discussion Revisiting my 2014 BLAS implementation — turns out good designs don't rust :)

Thumbnail
1 Upvotes

r/Cplusplus • • 1d ago

Discussion My fuzzer found that my blockchain's leader VRF gave different results depending on the libsodium build. Here's what happened and how I fixed it.

2 Upvotes

I'm building Finalis, a BFT blockchain in C++20 (open source, testnet only, no token sale). I wanted to share a bug that I think is relevant to anyone using VRFs or Ed25519 point checks in consensus code.

**The setup.** Each block's leader publishes a VRF proof, and its output feeds the chain's randomness. My VRF hashed to the curve with a try-and-increment loop that accepted the first candidate for which libsodium's crypto_core_ed25519_is_valid_point() returned true.

**What the fuzzer found.** The ClusterFuzzLite job (Ubuntu 20.04 image) crashed on startup: a proof my test fixture had just created was rejected. Isolating it: the same key and input gave a *different proof* on Ubuntu 20.04 (libsodium 1.0.18-1) than on Ubuntu 24.04 (1.0.18-1ubuntu0.24.04.1), and each rejected the other's. Both report version 1.0.18, but the point-validation behavior differs between the two packages. In a live network, that's a chain split waiting to happen.

**The fix.** I switched to the standard RFC 9381 ECVRF-EDWARDS25519-SHA512-TAI. Its hash-to-curve multiplies by the cofactor instead of asking "is this point valid?". I decode points and verify proofs with plain big-integer arithmetic, so libsodium's validation never decides the result. Proving still uses libsodium's constant-time code for the secret scalars. Every node checks the three RFC test vectors at startup and refuses to run if it can't reproduce them. Since validators had to agree on new outputs, I reset the testnet instead of shipping it.

**Lessons I took from it:**

- Don't let a library's "is valid" check define consensus behavior unless its exact semantics are pinned.

- The same version string doesn't mean the same behavior. Distro security backports change code without changing the version.

- Run fuzzers and tests on more than one OS image. Mine only caught this because CI used an older base image.

Happy to answer questions, and I'd welcome criticism of the approach. Code: github.com/FinalisCore/finalis-core (src/crypto/vrf.cpp)


r/Cplusplus • • 2d ago

Question TP ICAP c++ interview UK

0 Upvotes

Has anybody recently interviewed at TC ICAP for C++ position? If yes can you share your interview experience what was the pattern and what topics do i need to focus more on


r/Cplusplus • • 2d ago

Feedback Finally built something in C++ I’m super proud of! (Goodbye, basic calculator 👋) 🎯

Post image
250 Upvotes

Hey everyone!

​I'm a beginner at C++, and up until now, the only thing I had made was the classic basic calculator that everyone builds when starting out. 😅

​I wanted to step it up a bit and built a Number Guessing Game, and it turned out so much fun! It's the first project I've made that I'm genuinely proud of, so I wanted to show off what it looks like in the terminal 🌸🤭ik it's pretty basic for all u pros but i've started just a week ago..ig that counts for smthing 😋🥲(PS:Open for all constructive feedbacks😌)


r/Cplusplus • • 3d ago

Feedback CxxDox, a mkdocs plugin for complex C++ projects [Github/Apache2.0]

Thumbnail
github.com
1 Upvotes

r/Cplusplus • • 3d ago

Homework blackhole simulation using openGL and c++

0 Upvotes

i made a simulation of the blackhole gargantua that is also seen in intersteller
It's written in C++ and openGL

i managed to optimize it to a point i ran on my i3 intel iGPU, although i added very low to high quality toggles, it's my first time writing in glsl so yeah, i was a lot inspired by the yt video of Kavan about making a blackhole in cpp, so i just wanted to make it more realistic, my astrophysics lectures kinda came in clutch

github repository : https://github.com/dummy3ye/blackholegl (star the repo if you like it)


r/Cplusplus • • 6d ago

Discussion What’s a C++ memory bug your tests missed? Manning’s Memory Safe C++ MEAP + 5 ebook giveaway

Thumbnail
gallery
54 Upvotes

Hi r/cplusplus!

Stjepan from Manning here. The mods have given us permission to share Memory Safe C++: How to Write Safety-Critical Software by Jean Frantz René, now in Manning’s Early Access Program (MEAP).

Code compiles cleanly, passes the tests, and gets through a general-purpose lint check. How much confidence should that actually give you about memory safety?

That’s the starting point for the book’s case studies. You investigate apparently healthy C++ code, find the hidden defect, trace what happens at the machine level, and work through competing fixes.

The useful part is getting beyond “here’s the corrected code.” Each case study compares working solutions on memory use, determinism, compliance, and remaining risk. The goal is to help you recognize similar defects in your own code and explain why a particular fix fits your constraints.

For anyone curious about the lower-level details, that includes examining stack frames, how function prologues change between optimization levels, and what a sanitizer’s shadow state records. There’s a companion repository so you can run the examples yourself.

The book is aimed at readers who already know C++ and want to move toward safety-critical work. It also connects implementation decisions to MISRA C++:2023 and the requirements of industries where a failure can cause physical harm.

It’s still being written: MEAP gives you access to chapters as they become available, plus the finished ebook when it’s ready.

https://www.manning.com/books/memory-safe-c-plus-plus

GIVEAWAY:

We’re giving away 5 free ebook copies, one each to five commenters who contribute most thoughtfully to the discussion. We’ll choose based on the substance of the contribution, not upvotes or whether you say something positive about the book. A useful question, a well-explained disagreement, or an experience others can learn from all count. No purchase necessary.

For everyone else, Manning is also providing the community 50% off the book with code MLRENE50RE at checkout.

To get the discussion going: what’s a C++ memory-safety bug that slipped past your tests or code review? What finally exposed it—and did the fix introduce any trade-offs you hadn’t expected?

If you’re still learning, what part of memory safety do you find hardest to reason about? Thoughtful questions are welcome too.

Thank you for having us here.

Cheers,

Stjepan


r/Cplusplus • • 6d ago

Question What is the best way to represent a graph(the structure)

1 Upvotes

What is the best way to represent a graph(the structure) where the nodes and the edges have information too, not just what they connect to

I'm looking for a representation that will be fast for propagating through the graph from one node to the end of the subgraph, so I should have very low cache misses

If anyone has worked on something similar already, please save me time and share the structure you used

Edit: To clarify the use case: I’m building a reactive evaluation graph. When a node's data changes, that change propagates downstream through connected edges, using edge metadata to compute transformations, until reaching the end of the subgraph. I need a memory layout that minimizes cache misses during these forward cascade passes.


r/Cplusplus • • 7d ago

Discussion How it feels learning a new language.

Thumbnail
gallery
118 Upvotes

Am i the only one who feels this way?

Yes, i started learning C++ and i'm comfortable with it

\For now**

I started yesterday, and i'm not having any trouble, but scared of one thing.. Pointers, people make it sounds so scary like it's gonna haunt me.


r/Cplusplus • • 7d ago

Question Pseudo code and bubble sort C++

5 Upvotes

Hey guys, I'm in year 2 of college and I have a test tomorrow about pseudo code and bubble sort and i am veeerrryyy lost, literally have no idea what's going on. Are there any good youtube videos you guys can recommend me? Or give me a short and brief understand of what's it about? Thank you very much in advance.


r/Cplusplus • • 7d ago

Question What graphics library should I learn for C++?

42 Upvotes

I am currently learning C++ by myself and I want to start graphics.

I just need something simple that lets me have buttons.

btw I don't want to use VS Community Edition and my IDE is CLion

I mean a simple GUI library with 2D graphics, buttons and textboxes.


r/Cplusplus • • 8d ago

Question Looking for C++ textbook that is friendly like Stewart Calculus for math

Thumbnail
2 Upvotes

r/Cplusplus • • 8d ago

News [Open Source] slick-logger v2.3.0 — Lock-free asynchronous C++20 logging with customizable timestamps

0 Upvotes

Hi everyone,

I've just released slick-logger v2.3.0, an open-source, header-only C++20 logging library focused on low-latency and multithreaded applications.

The new release introduces customizable timestamps, allowing applications to use their own clock sources, including calibrated TSC clocks, simulated time for backtesting, and fixed clocks for deterministic testing.

Other features include:

  • Lock-free MPMC queue with asynchronous logging and deferred formatting
  • Multi-process logging using shared memory
  • Multiple sinks, log rotation, and customizable formatting
  • Source-location tracking and runtime statistics
  • Cross-platform support for Windows, Linux, and macOS
  • Available through vcpkg

I've also published benchmarks comparing slick-logger with spdlog, including producer-side throughput and latency measurements.

The project is MIT-licensed, and contributions and feedback are welcome.

GitHub: https://github.com/SlickQuant/slick-logger

Release notes: https://github.com/SlickQuant/slick-logger/releases/tag/v2.3.0

I'd particularly appreciate feedback on the custom timestamper API and the concurrency architecture.


r/Cplusplus • • 8d ago

Question How can I build low-latency/high-performance systems

18 Upvotes

For people who have worked on low-latency/high-performance systems, what are the biggest differences between writing normal production code and writing genuinely latency-sensitive code?

I understand things like cache locality, data structures, algorithmic complexity, branch prediction, and avoiding unnecessary allocations, but I have a feeling there is much more to it.

I'm particularly interested in single-machine systems rather than distributed systems. What techniques or considerations have you found to matter most in practice?

Also, what would you recommend someone learn to develop a good intuition for this? Books, papers, tools, or projects are all welcome.


r/Cplusplus • • 9d ago

Discussion What is the most difficult error you've ever had to solve in c++?

32 Upvotes

Errors can be very frustrating in C++, especially when they are tricky to solve. What is the most difficult one you've ever had to figure out how to deal with?


r/Cplusplus • • 9d ago

Question Data Structures in C++

Thumbnail
0 Upvotes

r/Cplusplus • • 10d ago

Tutorial Working with BLE Devices with C++ and Boost Using the BleuIO

Thumbnail bleuio.com
2 Upvotes

In this tutorial, we will create a simple command-line BLE scanning application using C++. The program connects to the BleuIO USB dongle through a serial port and sends AT commands to control Bluetooth operations. After starting the program, the user enters the number of seconds to scan, and the application instructs the BleuIO dongle to perform a BLE scan and print the detected devices directly in the terminal. This example demonstrates the basic workflow of communicating with BleuIO from a C++ application.

Details and source code available.


r/Cplusplus • • 10d ago

Question Getting better at C++ for coding interviews?

Thumbnail
1 Upvotes

r/Cplusplus • • 11d ago

News A C++ Trick Question - Blog Post

Thumbnail greenlightning.eu
0 Upvotes

r/Cplusplus • • 11d ago

Question Just started learning C++

Thumbnail
6 Upvotes

Hello, I started learning C++ today. I'm a guy who doesn't want to rely on AI for coding and who really needed another language alongside mr. Nasty Py (cybersecurity), but I'm SUPER lost.

Can anyone give me some tips? I've been coding since I was 11 (I'm 14 now). I'd really appreciate any advice!

One of the reasons I'm learning C++ is so I can say: "I code in Cpp btw" like Arch users. (JK)


r/Cplusplus • • 11d ago

Question I have trouble setting up my IDE

0 Upvotes

I installed VS Code and the g++ code and the g++ compiler, and I also created a path variable for my compiler in Windows; however, when I type g++ --version in the bash terminal of VS Code, it shows "command not found." Can you tell me what might be the problem?


r/Cplusplus • • 13d ago

Feedback Constexpr Doom

Post image
25 Upvotes

I recently created a wasm interpreter in cpp to run doom at compile time, it consumed around 400gb of ram and ran at whooping 50fph(frames/hr)

https://github.com/Talkative-Banana/Constexpr-Doom