0

In the stl implementation that comes along with Visual Studio 12.0 the numeric header looks like this

#pragma once
#ifndef _NUMERIC_
#define _NUMERIC_

// shortened for the sake of readibility
. 
.
.


#endif /* _NUMERIC_ */

I know that #pragma once is not standard conform.

Nevertheless, why did they implement a double header guard?

Lundin
  • 195,001
  • 40
  • 254
  • 396
schorsch312
  • 5,553
  • 5
  • 28
  • 57

1 Answers1

0

#pragma once: The same file will not be included multiple times include guard idiom:uses preprocessor macro definitions to prevent multiple inclusions of the contents of the file.

According to the Doc

There's no advantage to use of both the include guard idiom and #pragma once in the same file. The compiler recognizes the include guard idiom, and implements the multiple-include optimization the same way as the #pragma once directive if no non-comment code or preprocessor directive comes before or after the standard form of the idiom

I suggest you could refer to the link:https://stackoverflow.com/a/13339535/11872808

Jeaninez - MSFT
  • 3,210
  • 1
  • 5
  • 20