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

Use #pragma once as include guard #54

Open
bates64 opened this issue Mar 24, 2024 · 2 comments
Open

Use #pragma once as include guard #54

bates64 opened this issue Mar 24, 2024 · 2 comments
Labels
good first issue Good for newcomers

Comments

@bates64
Copy link
Owner

bates64 commented Mar 24, 2024

In many header files (*.h), we do something like

#ifndef NAME_OF_HEADER_H
#define NAME_OF_HEADER_H

// code here...

#endif

We're using a modern compiler now, so these could just be replaced by:

#pragma once

// rest of code here...

This applies to any and all header files, except for those where the macro that is defined is used elsewhere (e.g. #if DX pops up in places).

@bates64 bates64 added the good first issue Good for newcomers label Mar 24, 2024
@c0des1ayr
Copy link
Contributor

not an expert, but i'd assume it's best to avoid non-standard macros that may cause subtle errors in compilers that may not support it, no?

@bates64
Copy link
Owner Author

bates64 commented Dec 5, 2024

@c0des1ayr In general, you're right. However, #pragma once is supported in every widely-used compiler :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants