I had a general C++ style/design question. I noticed that in the WTL header files, there are some headers that you include yourself, and there are some that you just check for and throw errors if they haven't been included already. Could you explain how you make the distinction? I'm asking because I'm attempting to create some reusable class headers of my own, which involve various types of dependencies, and I'm trying to figure out what the best style and approach is. Thanks for any info.
Last edit: Bill Stevens 2021-04-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It depends what are you trying to achieve. My reasoning was this: Everything that is just assumed to be there (CRT, WinSDK headers) is included when needed; WTL and ATL headers were not. The idea was that nothing more than what is needed is included, and also for users to understand dependencies. Some headers were automatically included (in atlapp.h) because they were always needed.
It is also perfectly valid to do the opposite and to have a header like wtlall.h that includes all headers. It is a tradeoff between efficiency/understanding and ease of use.
I hope this helps.
Cheers,
Nenad
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I had a general C++ style/design question. I noticed that in the WTL header files, there are some headers that you include yourself, and there are some that you just check for and throw errors if they haven't been included already. Could you explain how you make the distinction? I'm asking because I'm attempting to create some reusable class headers of my own, which involve various types of dependencies, and I'm trying to figure out what the best style and approach is. Thanks for any info.
Last edit: Bill Stevens 2021-04-08
Hi Bill,
It depends what are you trying to achieve. My reasoning was this: Everything that is just assumed to be there (CRT, WinSDK headers) is included when needed; WTL and ATL headers were not. The idea was that nothing more than what is needed is included, and also for users to understand dependencies. Some headers were automatically included (in atlapp.h) because they were always needed.
It is also perfectly valid to do the opposite and to have a header like wtlall.h that includes all headers. It is a tradeoff between efficiency/understanding and ease of use.
I hope this helps.
Cheers,
Nenad