←back to thread

48 points zigrazor | 1 comments | | HN request time: 0.511s | 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 #
kookamamie ◴[] No.44524039[source]
No, it is the way. Edit: no one has time for inventing unique names for include guards.
replies(2): >>44524438 #>>44524781 #
hdhdjd ◴[] No.44524438[source]
Does anyone write those by hand anyway in any kind of project the size where it would matter?

#pragma once is broken by design

replies(3): >>44524590 #>>44524788 #>>44526846 #
jcelerier ◴[] No.44526846{3}[source]
Even if you don't write header guards by hand you get issues. The amount of time I got bitten by someone naming a file "widget.h" or "utils.hpp" three levels of libraries down with the corresponding #ifndef WIDGET_H which broke the build in incredibly mysterious ways...

https://github.com/search?q=ifndef+WIDGET_H&type=code

replies(1): >>44529468 #
1. tom_ ◴[] No.44529468[source]
I use a guid. (A different one each time, of course.)