Handmade Hero»Forums»Code
Tim Liou
2 posts
Day 11 - Why include ".cpp" instead of ".h"
Edited by Tim Liou on
Hi, all!
First, Sorry for my poor english.

I just finish Day 11 of Handmade Hero. I really love this project and learn a lot from it. I'm a freshman in college and a computer science major. I learned to program in C last semester. When I learned about the header part, my teacher taught us that we should never include a c/cpp file. Instead of doing so, he said that we should include .h files. As I know so far (my poor knowlege), we make declarations in header files and implement them in c/cpp files. Then, compiler will generate .o files and link them into executable file. Is it correct? I wonder why Casey include .cpp file instead of .h file.

Thanks!
David Owens II
69 posts
A software engineer that enjoys living in enemy territory.
Day 11 - Why include ".cpp" instead of ".h"
It's called a unity build. There are no other object files created that need to be linked together.
Tim Liou
2 posts
Day 11 - Why include ".cpp" instead of ".h"
Oh... OK, I got it.
Thank you! owensd.
Ben
6 posts
Day 11 - Why include ".cpp" instead of ".h"
It's supposed to make things faster. Although, C++ compilers take significantly longer than C compilers.