+ 11
Why (or why not) use pragma once over ifndef?
2 odpowiedzi
+ 9
Although #pragma once is less code to deal with (and less code to deal with == overall less bugs) and arguably widely practiced, it is non-standard. If portability is not your concern and you are not a total purist, then this shouldn't be an issue.
+ 7
`#pragma once` isn't standard C++. I believe it used to be a Microsoft Visual C++ thing, but these days every major compiler can handle it.
I don't see a reason not to use it, unless your compiler can't do it, or unless your code is used by many people (and hence many compilers).