katang Posted April 23, 2017 Report Share Posted April 23, 2017 In the book "SystemC from the Ground Up" book, page 57, an implementation style is suggested which seems to be reasonable. However, when I attempt to compile it, I am presented with the message error: expected constructor, destructor, or type conversion before '(' token NAME::NAME(sc_module_name nm) ^ Did something change in the syntax since the book appeared? (the other form compiles and runs fine) Quote Link to comment Share on other sites More sharing options...
AmeyaVS Posted April 23, 2017 Report Share Posted April 23, 2017 Hello @katang, It seems the macro NAME has not been defined. From the book they have mentioned about the file "NAME.h". There recommendation on providing simpler and cleaner declarations. Regards, Ameya Vikram Singh Quote Link to comment Share on other sites More sharing options...
katang Posted April 23, 2017 Author Report Share Posted April 23, 2017 I do not know. This is the complete file, header inserted. #include <systemc> SC_MODULE(NAME) { SC_CTOR(NAME); }; SC_HAS_PROCESS(NAME); NAME::NAME(sc_module_name nm) : sc_module(nm) {} And the error message NAME.cpp:6:11: error: expected constructor, destructor, or type conversion before '(' token NAME::NAME(sc_module_name nm) ^ g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 Quote Link to comment Share on other sites More sharing options...
AmeyaVS Posted April 23, 2017 Report Share Posted April 23, 2017 Hello @katang, The error spawns from not specifying the namespace resolution correctly. Following code compiles without errors: NAME.h: #ifndef NAME_H_ #define NAME_H_ #include <systemc> SC_MODULE(NAME) { SC_CTOR(NAME); }; #endif // NAME_H_ NAME.cpp: #include "NAME.h" SC_HAS_PROCESS(NAME); NAME::NAME(sc_core::sc_module_name nm) //< Added sc_core namespace resolution. : sc_core::sc_module(nm) //< Added sc_core namespace resolution. {} Regards, Ameya Vikram Singh swami-cst 1 Quote Link to comment Share on other sites More sharing options...
katang Posted April 23, 2017 Author Report Share Posted April 23, 2017 Thanks a lot. In my eyes the g++ error message is misleading. I was looking also for the error in defining macro NAME. Quote Link to comment Share on other sites More sharing options...
Ganesan R Posted January 25, 2018 Report Share Posted January 25, 2018 Hi Ameya Singh, How to add destructor for NAME in this example? Thanks. Quote Link to comment Share on other sites More sharing options...
AmeyaVS Posted January 25, 2018 Report Share Posted January 25, 2018 Hello @Ganesan R, Since it is usual C++ code. You just need to define it as in C++. For e.g.: #include "NAME.h" SC_HAS_PROCESS(NAME); NAME::NAME(sc_core::sc_module_name nm) //< Added sc_core namespace resolution. : sc_core::sc_module(nm) //< Added sc_core namespace resolution. {} ////////////////////////////// // Check below ///////////////////////////// NAME::~NAME() { // You Destructor body } Hope it helps. Regards, Ameya Vikram Singh Quote Link to comment Share on other sites More sharing options...
Ganesan R Posted January 29, 2018 Report Share Posted January 29, 2018 Thanks a lot Ameya Singh. It helped really. Very timely help, but could not work on due to my illness. R. Ganesan 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.