Hi Artyom, You're absolutely right that the tutorial needs to be updated! The website is also open source and managed via a git repo: https://gem5.googlesource.com/public/gem5-website/. Updating this would be a good way to get started contributing to gem5 :).
By the way, for the namespace, you can also wrap the file in the following so you don't have to explicitly use namespaces everywhere: ``` namespace gem5 { <your code> } ``` Cheers, Jason On Sat, Mar 26, 2022 at 10:57 PM Artyom Liu via gem5-users < gem5-users@gem5.org> wrote: > Hi, > > The problem is solved by literally adding a new parameter `sim_objects`. > > > SimObject("HelloObject.py", sim_objects = ["HelloObject"]) > > But I find yet another problem with the tutorial: the code that use > classes from gem5 is missing namespace declaration. For example, the > class `SimObject` is under namespace `gem5`, but the tutorial is using > it directly. It makes the compiler unable to find the class. > > ``` > #ifndef __LEARNING_GEM5_HELLO_OBJECT_HH__ > #define __LEARNING_GEM5_HELLO_OBJECT_HH__ > > #include "params/HelloObject.hh" > #include "sim/sim_object.hh" > > class HelloObject : public SimObject > { > public: > HelloObject(const HelloObjectParams &p); > }; > > #endif // __LEARNING_GEM5_HELLO_OBJECT_HH__ > ``` > > For the compiler to work, we should use `gem5::SimObject` instead. And > `gem5::HelloObjectParams` for the same reason. > > None of the problems are mentioned in the tutorial. I wonder if it is > necessary to *update* the tutorial? > > Artyom > artyom...@hust.edu.cn > > On 3/27/22 10:05, Artyom Liu wrote: > > Hi, > > > > I'm new to gem5 and just start learning by following the tutorial on > > gem5.org. However, there's a problem when I try to create my custom > > object[1]. > > > > [1]: https://www.gem5.org/documentation/learning_gem5/part2/helloobject/ > > > > I follow exactly the guide, but I fail to re-compile with scons. The > > error message as below. > > > > > Error: SimObject(HelloObject.py...) must list c++ sim_objects or > > enums > (set either to [] if there are none). > > > > My gem5 version is Version 21.2.1.0, and I noticed that there's an *API > > change* about SimObject declaration in Version 21.2.0.0, requiring that > > sim_object parameter of SimObject declaration "should list all SimObject > > classes which have a type attribute defined". > > > > It matches the error message. So I wonder how could I change my > > SConscript to fit this change? My current SConscript is from the > tutorial. > > > > ``` > > Import("*") > > > > SimObject("HelloObject.py") > > Source("hello_object.py") > > ``` > > > > Artyom > > artyom...@hust.edu.cn > _______________________________________________ > gem5-users mailing list -- gem5-users@gem5.org > To unsubscribe send an email to gem5-users-le...@gem5.org > %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s >
_______________________________________________ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s