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

Modernize include guards and add missing ones #9898

Merged
merged 2 commits into from
May 23, 2020
Merged

Modernize include guards and add missing ones #9898

merged 2 commits into from
May 23, 2020

Conversation

Awkor
Copy link
Contributor

@Awkor Awkor commented May 20, 2020

This PR converts the remaining #ifndef header guards to #pragma once.

I used guard2once from guardonce to do the conversion.

@@ -18,8 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef CLIENT_HUD_HEADER
#define CLIENT_HUD_HEADER
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure the #ifndef was left untouched on purpose, because there are two header files with the same name:

  • src/hud.h
  • src/client/hud.h

Would #pragma once take this quirk into account?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I've gathered from here, here and here, I think this quirk should be handled correctly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does indeed seem to be the case, thanks for clarifying.

@SmallJoker SmallJoker added the Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements label May 20, 2020
@orbea
Copy link
Contributor

orbea commented May 22, 2020

#pragma once is not standardized, ifdef guards are. This seems much more likely to introduce problems than solve them.

@SmallJoker
Copy link
Member

@orbea A while back #pragma once was decided to be widely supported, and thus accepted as header guard for Minetest. Somewhere there's a PR about this.

@Awkor While you're at it - would you please be so nice and include the missing guards as mentioned in #9899 (comment) ?

@ClobberXD
Copy link
Contributor

#pragma once is supported on all mainstream compilers, even if it isn't a part of the C++ specification itself. See https://en.wikipedia.org/wiki/Pragma_once#Portability

@Awkor Awkor changed the title Modernize include guards Modernize include guards and add missing ones May 22, 2020
@Awkor
Copy link
Contributor Author

Awkor commented May 22, 2020

@SmallJoker Done.

src/gui/guiSkin.h Outdated Show resolved Hide resolved
@SmallJoker SmallJoker merged commit 037422f into minetest:master May 23, 2020
@Awkor Awkor deleted the modernize-include-guards branch May 23, 2020 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements >= Two approvals ✅ ✅
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants