I know there are two ways to prevent a header file from being duplicated in C \ C ++:
#ifndef FOO_H_INCLUDED
#define FOO_H_INCLUDED
class Foo
{
// código
};
#endif
E
#pragma once
class Foo
{
// código
};
Being the first I see in almost 100% of the open source libraries out there. So my question is: if the second form is simpler and supported by the main compilers (gcc, msvc, intel, clang), what's wrong with using #pragma once
? And what difference do these approaches make to the compiler?