oogabooga's Avatar
Ambitious contributor
Macro guards are the preferred method for ensuring single inclusion.
It is more portable and does not have the problems of #pragma once
(cannot know that the same file is included under two different names
as can occur with links on unix, etc.).
gcc considers #pragma once to be deprecated.
These are macro (or include) guards:
Code:
// header.h
#ifndef HEADER_H
#define HEADER_H
...
#endif
asadullah.ansari's Avatar, Join Date: Jan 2008
TechCake
In pragma once same code is written as you have written.
princemaozh's Avatar, Join Date: Aug 2007
Light Poster
Salem, thank you very much for the explanation.

Shabbir and others, also thanks for your comments.