So I know how to place an include guard in my own header files with the standard
#ifndef ...
#define ...
Now, My question is about including libraries that are not my own. would be a good example. I have a header file which requires the use of string, so I do the following
foo.h
#ifndef FOO_H
#define FOO_H
#include <string>
... code etc ...
#endif
Now, if I have another header file called.. lets say, bar.h
, which ALSO requires the use of <string>
, how can i prevent multiple inclusions? Does the STL already have include guards in place?
#pragma once
- their proprietary version of header guards. Which is fine: the "STL" is nowadays part of the compiler, and therefore can use compiler-specific language extensions. – Metalliferous