IWYU Question

105_bt_urc
battle-tank

#1

In this video Sam utilizes IWYU and adds:

#include "PhysicsEngine/PhysicsConstraintComponent.h"

He places this include in SprungWheel.cpp. I’m just curious why we didn’t place this in SprungWheel.h because it is from my understanding so far that we put all of the includes in the header file and then just have a single include of the SprungWheel.h in the .cpp.

I know it’s not a huge deal, but to reinforce my understanding of what I thought I had picked up in previous lectures, which route is more correct here?


#2

This is incorrect. You should forward declare in headers as much as you can and only include if you absolutely require it. As if you include everything in the header then that means every header that includes your header will also have to include those even if they don’t need them.


#3

Thanks Dan, and hey Lockshot.

If that’s answered your question remember click the solved checkbox, either of you can do that.


automatically bumped #4

automatically bumped #5

automatically bumped #6

automatically bumped #7

automatically bumped #8

#9

Hey Dan,

Thanks for clarifying this question for me with reasoning to back things up. Big help!

Mike


closed #10

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.