←back to thread

48 points zigrazor | 1 comments | | HN request time: 0.001s | source

Hi HN!

I've built [CXXStateTree](https://github.com/ZigRazor/CXXStateTree), a modern C++ header-only library to create hierarchical state machines with clean, intuitive APIs.

It supports: - Deeply nested states - Entry/exit handlers - State transitions with guards and actions - Asynchronous transitions with `co_await` (C++20 coroutines) - Optional runtime type identification for flexibility

It's ideal for complex control logic, embedded systems, games, robotics, and anywhere you'd use a finite state machine.

I’d love feedback, use cases, or contributions from the community!

Repo: https://github.com/ZigRazor/CXXStateTree

Show context
dgan ◴[] No.44523973[source]
i am by no means a C++ expert, but isn't "pragma once" frowned upon?
replies(5): >>44524039 #>>44526928 #>>44526935 #>>44528279 #>>44529097 #
1. benreesman ◴[] No.44528279[source]
You'll see a fairly even split amongst S-tier, "possibly headed for standardization" level libraries. I'd say there's a skew for `#ifndef` in projects that are more "aspires to the standard library" and for `#pragma once` in projects that are more focused on like a very specific vertical.

`#pragma once` seems to be far preferred for internal code, there's an argument for being strictly conforming if you're putting out a library. I've converted stuff to `#ifndef` before sharing it, but I think heavy C++ people usually type `#pragma once` in the privacy of their own little repository.

- `spdlog`: `#pragma once` https://github.com/gabime/spdlog/blob/v1.x/include/spdlog/as...

- `absl`: `#ifndef` https://github.com/abseil/abseil-cpp/blob/master/absl/base/a...

- `zpp_bits`: `#ifndef` https://github.com/eyalz800/zpp_bits/blob/main/zpp_bits.h

- `stringzilla` `#ifndef` https://github.com/ashvardanian/StringZilla/blob/main/includ...