Skip to content

(MINOR) Use #pragma once instead of explicit header guards  #260

Description

@shlomnissan

#pragma once is often preferred over header guards because it simplifies the code and reduces the chances of errors. #pragma once eliminates the need for manual definition of unique macros to prevent multiple inclusions. This reduces boilerplate code and the potential for mistakes, such as mistyping the macro names or accidentally reusing the same macro in different files. It can also potentially speed up compilation times, as the compiler can optimize the file inclusion process more effectively than with traditional header guards.

It's worth noting that while most modern compilers support #pragma once, it is not part of the C++ standard, so some very old or niche compilers might not support it. I don't think we need to worry about it considering the compilers we are targeting, but I just wanted to call it out.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions