Handmade Hero»Forums»Code
6 posts
Unity Build and header file(.h) question
Edited by GunnGames on
I'm not following along with the handmade hero series, but taking bits and pieces from it for my own project. I currently use a unity build and love it. My question is in regards to header files. It's an oop habit of mine to have function declarations in header files, and so far I haven't broken that habit. Is this going to be an issue? I haven't run across any issues yet, so I'm just curious. I know in HH he tends to keep only data, mostly structs in his header files.

I'm doing my best to unlearn and/or forget the years of OOP I've done, in hopes to learn a different programming style. I really like the way HH breaks the OOP cycle, just not sure if I'm on the right track yet. It compiles and only generates a single .OBJ file (using VS), and only G3D.cpp gets compiled, so I must be doing something right. Below is a git repo of my current code and what I'm talking about. Appreciate any feedback!

GIT: https://github.com/GunnDawg/Gunngine3D/tree/master/G3D/src
4 posts
Unity Build and header file(.h) question
Edited by n00bmind on
Shouldn't be an issue at all.

The thing with a unity build is that, if you get your order right, you _may not need to_ forward declare most things, since by the point they're used you may have included the full body of the thing already, be it a struct or a function or whatever. Again, you need to get your order of inclusion right of course.

I find I sometimes need to forward declare things anyway, because you sometimes have mutual dependencies among things etc., but you can certainly get away with far less forward declarations in a unity build in general.

If your habit is forward declare everything, you can still do so, of course, which could help if you ever want to break down your unity build into different pieces for whatever reason.