Allen yang Posted November 16, 2023 Report Share Posted November 16, 2023 I read the source code a period of time. However I found that it din't use sp(smart pointer) in our source code. Is there any reason why we don't use sp in sc? Quote Link to comment Share on other sites More sharing options...
David Black Posted November 16, 2023 Report Share Posted November 16, 2023 For many years, SystemC used C++98/03. The latest version of the standard (2023) moves to C++17. So I expect to see more smart pointers (esp. unique_ptr<T>). There are certainly practitioners already using smart pointers in their code; however, example code usually constrained itself to the pre-C++11 standard. I suggest using the make_unique<T>() and make_shared<T>() methods because they have some extra safety over using new. Be careful to use the right type of smart pointer to avoid unnecessary overhead. I suggest you read the C++ Core Guidelines. Important: You will need the SystemC library to be compiled for the C++ version you use. I suggest building the modern way with cmake. Quote Link to comment Share on other sites More sharing options...
Allen yang Posted November 17, 2023 Author Report Share Posted November 17, 2023 Thanks @David Black I use systemc-2.3.3 complied with c++17 which supports sp. However, I use TLM property set_data_ptr and found it can't use smart pointer as argument. Do we have plan to rewrite our sc source code to support sp as arguments? Quote Link to comment Share on other sites More sharing options...
David Black Posted November 27, 2023 Report Share Posted November 27, 2023 Good point. I don't know that there are any plans currently. Probably needs to be suggested. Both unique_ptr and shared_ptr overloads would be good. You could of course extend the class and add your overload. Caution: if used in bridges or adapters, there may be additional considerations. So you need to be careful to consider the expanded situation. You may want to consider for what situations you wish to do this. Many use cases simply don't warrant smart pointers because the data is persistent or static. 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.