I would like to know why we use ".hh" as extension for C++ header files instead of using just ".h".
The header files are preprocessed and the preprocessor doesn't even care about the extension of the header file. So, even if I create a header file with an extension ".qwe" (test.qwe). Then, why to use ".hh" as extension for C++ header files.
Some say, we are using ".cc" as extension for C++ files to differentiate from C files (which has an extension ".c"), likewise we are using using ".hh" as extension for C++ header files to differentiate from C header files (which has an extension ".h"). I don't think this to be a valid reason.
Does anyone know the reason for naming in such a way?
What is an HH file? A file with . hh extension is a C++ header file that includes the declaration of variables, constants, and functions. These declarations are used by the corresponding C++ implementation files, usually saved as . cpp files that contain the actual implementation of user logic.
You should use the . hpp extension if you're working with C++ and you should use . h for C or mixing C and C++.
These preprocessor directives are used for instructing compiler that these files need to be processed before compilation. In C program should necessarily contain the header file which stands for standard input and output used to take input with the help of scanf() and printf() function respectively.
Without a header file, you cannot run or compile your program code. In C, all program codes must include the stdio. h header file.
Some say, we are using ".cc" as extension for C++ files to differentiate from C files (which has an extension ".c"), likewise we are using using ".hh" as extension for C++ header files to differentiate from C header files (which has an extension ".h").
That is exactly the reason. It is just to differentiate CPP headers from C headers.
Some programmers and libraries, such as Boost, use .hpp
for CPP headers. My personal choice is this:
Even if they all belong to a huge project, you can still figure out which one is which. No description is needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With