Reputation: 1163
I have used the same typedef
in two different header files i.e. in both "clientMsgHandling.h" and "connectivity.h" I have chosen to exactly implement typedef std::list<int> listInt;
.
I chose to do this instead of including "connectivity.h" in "clientMsgHandling.h" or vice versa, so it would be clearer in design (to me) and I am under the impression that this is a design choice i.e. no right and wrong.
Both "clientMsgHandling.h" and "connectivity.h" are included in main.cpp, and I would like to use listInt
in main()
.
My question is if this cause any issues? Both typedefs are exactly the same, and is this still a design issue or are there compiler-safety issues involved now? I don't have a compiler error in using it, but I would like to make sure there isn't something untoward happening that I am unaware of.
Upvotes: 0
Views: 1120
Reputation: 2885
If you have concerns about the design, why don't you move the typedef to its own .h file? Just wrap it between the proper #ifndef... #endif
In this way the compiler will see it only once.
Upvotes: 2