Hello gem5 developers,
My team is working on Cache coherence protocol.
In our designed protocol, we really need to count
the number of created objects in the system.
Such as, How many NetDest's objects were created.
So, I tried to use static variable to count.
This is what I've done.
In NetDest.cc and NetDest.hh
1. Declare "static int ObjCounter;" in class declaration.
2. Add ObjCounter++; in NetDest's constructor.
3. Add ObjCounter--; in NetDest's deconstructor.
4. Add new method "int getObjCounter() const { return ObjCounter; }" to
get the value.
I got this error. "undefined references to `NetDest::ObjCounter'"
So, I add "int NetDest::ObjCounter = 0;" Outside class declaration to set
the initial value.
Then, I got an another error.
"multiple definition of `NetDest::ObjCounter'"
This way work fine with normal c++.
Please let me know if we can fix this. Thank you everyone
Regards,
Pisacha Srinuan.
_______________________________________________
gem5-users mailing list
[email protected]
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users