aarone Posted September 3, 2015 Report Posted September 3, 2015 Hi guys! I'm new to SystemC and still trying to figure out basic stuff. In preparation to pass some arguments to a constructor, I'm looking how to replace the SC_CTOR macro. In the code below, the "SC_CTOR(my_module);" line works well but when I comment it out and replace by direct constructor declaration "my_module(sc_module_name nm);" it doesn't compile. I'll appreciate any hint. Thanks, Aaron --------------------------------------------- // main.cpp #include <systemc> #include "my_module.h" using namespace sc_core; int sc_main(int argc, char* argv[]) { my_module my_module_i("my_module_i"); sc_start(); return 0; } // my_module.h #ifndef MY_MODULE_H #define MY_MODULE_H #include <systemc> SC_MODULE(my_module) { // this constructor works SC_CTOR(my_module); // this constructor doesn't work //my_module(sc_module_name nm); };//endclass #endif // my_module.cpp #include <iostream> using std::cout; using std::endl; #include <systemc> #include "my_module.h" using namespace sc_core; SC_HAS_PROCESS(my_module); my_module::my_module(sc_module_name nm) : sc_module(nm) { cout << "Hello world" << endl; } Quote
kartikkg Posted September 3, 2015 Report Posted September 3, 2015 Hi it works for me , here is the code // main.cpp #include <systemc> #include "my_module.h" using namespace sc_core; int sc_main(int argc, char* argv[]) { my_module my_module_i("my_module_i"); sc_start(); return 0; } // my_module.h #include <systemc> using namespace sc_core; // my_module.h #ifndef MY_MODULE_H #define MY_MODULE_H #include <systemc> SC_MODULE(my_module) { // this constructor works //SC_CTOR(my_module); // this constructor doesn't work my_module(sc_module_name nm); };//endclass #endif & // my_module.cpp #include <iostream> using std::cout; using std::endl; #include <systemc> #include "my_module.h" using namespace sc_core; SC_HAS_PROCESS(my_module); my_module::my_module(sc_module_name nm) : sc_module(nm) { cout << "Hello world" << endl; } I used g++ costr.cpp my_module.cpp -lsystemc to compile. Can you check this if it works? else can you post your compiler errors? aarone 1 Quote
aarone Posted September 3, 2015 Author Report Posted September 3, 2015 Thanks Kartik, I see that now. I was missing the using namespace sc_core; in the header file before use of sc_module_name. Thanks, Aaron Quote
aarone Posted September 3, 2015 Author Report Posted September 3, 2015 BTW, how do you insert so nicely formatted code into the posts here? Thanks, Aaron Quote
kartikkg Posted September 3, 2015 Report Posted September 3, 2015 BTW, how do you insert so nicely formatted code into the posts here? Thanks, Aaron Glad that I was of help. You can format the code by first pasting the code here and then selecting the code and clicking on <> present in the options. aarone 1 Quote
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.