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

Is it ok to use #pragma once instead of #define CROW_STUFF_H in crow's header files? #814

Closed
Nabzokek opened this issue May 10, 2024 · 3 comments
Labels
question Issue can be closed by providing information

Comments

@Nabzokek
Copy link
Contributor

This isn't more than a suggestion, but I think that use #pragma once isn't the more recommended way to define header files, considering we want to make CrowCpp a cross platform library.

When you search for #pragma once in the project files you will see so much files with this line.

This is not so bad, but maybe it would be better if we use #define CROW_THING_H in the library header files instead of the not standard #pragma once lines.

@gittiver gittiver added the question Issue can be closed by providing information label May 12, 2024
@gittiver
Copy link
Member

It would make sense to add header guards and to leave pragma in addition in the file.
#pragma once is non standard but supported by most compilers.

So we should end up with:
#ifdef CROW_THING_H
#define CROW_THING_H
#pragma once
...
#endif /* #ifdef CROW_THING_H */

@Nabzokek
Copy link
Contributor Author

It seems fine to me, but in that case, using the #pragma once would no longer make sense, because header guards already solve that problem.
We can leave the #pragma once as well, but I don't think it would make much sense anymore.

@gittiver
Copy link
Member

It would only help a little bit on compile times (for some compilers).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issue can be closed by providing information
Projects
None yet
Development

No branches or pull requests

2 participants