GithubHelp home page GithubHelp logo

Comments (5)

quantum-leaps avatar quantum-leaps commented on June 7, 2024

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.

vanem avatar vanem commented on June 7, 2024

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.

quantum-leaps avatar quantum-leaps commented on June 7, 2024

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.

vanem avatar vanem commented on June 7, 2024

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.

quantum-leaps avatar quantum-leaps commented on June 7, 2024

OK, I fixed the issues noted for posteriority.

from state-oriented-programming.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.