Creating a new header file

I'm having an issue were when I create a new file and put it in the same directory as the others in the code folder that file can't be detected when building. It's a header file and it has the same include guards as the other header files being used in Handmade Hero. If you could help I'd be very grateful!

Also I created the file by copying one of the header files in the code folder and renaming it. Are there any flaws or risks creating the file like that?

Thanks for reading!

Partyslug

Edited by CJ Nelson on
Partyslug
I'm having an issue were when I create a new file and put it in the same directory as the others in the code folder that file can't be detected when building. It's a header file and it has the same include guards as the other header files being used in Handmade Hero.


How are you #include'ing the header file? Be sure to use the quotes to specify that the file is in the same directory as the .cpp file #include'ing it from.

1
2
3
// Assuming this is in file.cpp

#include "file.h"


Partyslug
Are there any flaws or risks creating the file like that?


I don't believe there are any flaws or risks doing this (someone correct me if I am wrong), just be sure to change the header guards to the appropriate file name.

Jordan

Edited by Jordan Duval on
Since we build as a single translation unit, there is actually no need for include guards in Handmade Hero. In fact, I think we removed them recently if I remember correctly?

Anyway, I'm not sure what the problem is that you're encountering, but I was worried by the phrase "detected". I wanted to make sure it was clear that there is nothing in the build that _gathers_ include files. They are always manually added into the code by adding a #include at the appropriate place where the file is supposed to be included. Have you done that?

- Casey
I found out that it was the way I was creating the file that was the problem after all. A header file created in a text editor was able to be found by the compiler.

Thank you both for reading and replying to my post!