I have gotten to a point in my course where they use Code::Blocks to automatically make a header file. However, I don't think it's necessary to download Code::Blocks specifically for this reason, and so I am looking for a way to make my own header files.
And so, I started my search online to find out exactly how to do this. I checked How to create my own header file in c++? [closed] and also cplusplus.com
However, the former uses uses #ifndef YOUR_NAME_INCLUDE
and #define YOUR_NAME_INCLUDE
whereas the latter uses #ifndef __X_H_INCLUDED__
and #define __X_H_INCLUDED__
, with 2 underscores surrounding the #ifndef
and #define
. How should I format my header guards? Does it really matter?
For example, if I have a file foo.h
, which looks like this:
#ifndef ???
#define ???
int sum(int a, int b) {
return a + b;
}
#endif
should I put SUM_INCLUDED
, FOO_INCLUDED
, FOO_H
instead of the ???
or something else altogether?
Second, is making a header file really as easy as just sticking a .h
or .hpp
to the end of it?