IWYU Question

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?

1 Like

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.

1 Like

Thanks Dan, and hey Lockshot.

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

Hey Dan,

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

Mike

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

Privacy & Terms