C++ header file repeated inclusion problem

In order to avoid the same file being included multiple times, there are two ways:
1

#ifdef _SOMEFILE_H_
#define _SOMEFILE_H_
#endif

Use macros to prevent the same file from being included multiple times;
advantages: good portability ;
disadvantages: unable to prevent duplication of macro names, difficult to debug


 #pragma once

Use a compiler to prevent the same file from being included multiple times.
Advantages: can prevent macro duplication and easy to debug.
Disadvantages: poor portability

Guess you like

Origin blog.csdn.net/yasuofenglei/article/details/108579130