Comments (5)
Thanks for your interest in this older article (from 2000!).
I've updated the code to compile with options "-pedantic -Wall -Wextra".
Please check if this compiles with your g++ 11.
--MMS
from state-oriented-programming.
Thank you for responding!! I was aware that this is based on such an old article, and I know about QP, but this is such a great and simple pattern for what it's able to achieve (and with no other external dependencies). I already used in C and Python (and not only in embedded).
Regarding your code changes, g++ still gives an error message:
watch.cpp:211:41: error: ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function. Say ‘&Watch::topHndlr’ [-fpermissive]
211 | : Hsm("Watch", static_cast<EvtHndlr>(&topHndlr)),
| ^~~~~~~~
but at least the message is meaningful, and the suggested change solves the problem, no more errors/warnings with casts like this:
: Hsm("Watch", static_cast<EvtHndlr>(&Watch::topHndlr)),
There are also complains for the use of register
, but that's obvious.
PS: I apologize, I somehow missed the paragraph in this project readme Notes About C++ Implementation, where the cast reinterpret_cast<EvtHndlr>(&<class>::<func>)
is suggested for newer non-embedded compilers
from state-oriented-programming.
I've changed the casts in the C++ example code (watch.cpp and hsmtst.cpp) to use reinterpret_cast<EvtHndlr>(...)
. I hope this will compile and run.
--MMS
from state-oriented-programming.
It does work for me on Ubuntu/x86/gcc11.4.0 c++ standard >=11, by using casts in the form:
reinterpret_cast<EvtHndlr>(&<class>::<func>))
or static_cast<EvtHndlr>(&<class>::<func>))
for example:
static_cast<EvtHndlr>(&Watch::timekeepingHndlr)
or reinterpret_cast<EvtHndlr>(&Watch::timekeepingHndlr)
Having the fully qualified methodname <class>::<func>
is required for an error free build
I closed the issue, thank you!
from state-oriented-programming.
OK, I fixed the issues noted for posteriority.
from state-oriented-programming.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from state-oriented-programming.