Handmade Hero»Forums»Code»Unity Build and header file(.h) question
6 posts
Unity Build and header file(.h) question
1 month, 3 weeks ago Edited by GunnGames on Feb. 16, 2020, 11:04 a.m.
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!

3 posts
Unity Build and header file(.h) question
1 month, 3 weeks ago Edited by n00bmind on Feb. 16, 2020, 11:34 a.m.
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.