Quoting from Microsoft documentation, There is no advantage to use of both the #include guard idiom and #pragma once in the same file.
Answers to previous related questions on stackoverflow also confirm that it is pointless to have both. See below, for instance:
Header guards and pragma once
The boost
library's vector.hpp
file, however, starts thus:
#ifndef BOOST_ASSIGN_STD_VECTOR_HPP
#define BOOST_ASSIGN_STD_VECTOR_HPP
#if defined(_MSC_VER)
# pragma once
#endif
...
#endif
That is, it includes both the guard idiom as well as the pragma once. Is there any reason why boost header files have both?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…