Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
shlomnissan opened this issue Jul 2, 2024 · 0 comments
Open

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

shlomnissan opened this issue Jul 2, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@shlomnissan
Copy link
Collaborator

#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

1 participant