Flori_He Posted April 20, 2016 Report Share Posted April 20, 2016 Hello everyone,I tried to use code from the SystemC Verification StandardSpecification. It can be found on page 46 and reads: class my_module : public sc_module {public: scv_smart_ptr<int> fsm_state; SC_CTOR(my_module) { fsm_state->register_cb(fsm_state_callback); } void fsm_state_callback(scv_extensions_if& data, scv_extensions_if::callback_reason r) { if ( r == scv_extensions_if::VALUE_CHANGE) { cout << "The FSM state has been changed to : " << data << endl; // write_to_the_database(data); } }};Compiling this with the respective haeders and libraries, I get the error.my_mod.cpp: In constructor ‘my_module::my_module(sc_core::sc_module_name)’:my_mod.cpp:11:42: error: no matching function for call to ‘scv_extensions<int>::register_cb(<unresolved overloaded function type>)’ fsm_state->register_cb(fsm_state_callback); ^I already searched for a solution and found that there seems to be a problem with: pointer-to-member-function vs pointer-to-function are different and incompatibleThis seems to be the case here as the definition of the function in the API reads:virtual callback_h register_cb(void (*f)(scv_extensions_if&, callback_reason)) = 0;In the above example I try to register a pointer-to-member-function to a pointer-to-function which leads to the error (as I understand it).So is there any known solution to the problem?Regards,Florian Quote Link to comment Share on other sites More sharing options...
Stephan Gerth Posted April 21, 2016 Report Share Posted April 21, 2016 Hi Florian, you understood the problem correct, it seems the example wasn't tested ("can be performed using code similar to..."). However, a quick solution would be to move the fsm_state_callback function out of the class and thus make it a C-function. Quote Link to comment Share on other sites More sharing options...
Flori_He Posted April 21, 2016 Author Report Share Posted April 21, 2016 Hello Stephan,yes I tried this out, but when moving this function out of the class or keeping it in the class and making it a static member, I cannot work on any member variables (of objects) of the class.Regards Florian Quote Link to comment Share on other sites More sharing options...
Stephan Gerth Posted April 21, 2016 Report Share Posted April 21, 2016 That's right, register_cb would be probably need some kind of overload for member-function-pointers. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.