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

clean: just use #pragma once #1919

Merged

Conversation

shenlebantongying
Copy link
Collaborator

@shenlebantongying shenlebantongying commented Nov 7, 2024

Very random, but the “include once” problem was solved perfectly for almost 4 decades ago. See Page 72 about #import of Objective-C which was invented in literally 1984 https://www.gnustep.org/resources/documentation/ObjectivCBook.pdf

Code is converted by https://github.com/cgmb/guardonce

@shenlebantongying shenlebantongying changed the title clean: Just use #pragma once to stop IDE warnings clean: Just use #pragma once Nov 7, 2024
@@ -1,3 +1,5 @@
#pragma once
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It does catch an issue here, this file is not guarded.

@shenlebantongying shenlebantongying changed the title clean: Just use #pragma once clean: just use #pragma once Nov 7, 2024
Copy link

sonarcloud bot commented Nov 7, 2024

@shenlebantongying shenlebantongying merged commit 618310f into xiaoyifang:staged Nov 7, 2024
8 checks passed
@shenlebantongying shenlebantongying deleted the clean/pg-once branch November 7, 2024 03:53
@xiaoyifang
Copy link
Owner

See Page 72 about #import of Objective-C which was invented in literally 1984

Does this rule has been applied by c++ group or standards?

@shenlebantongying
Copy link
Collaborator Author

It is not on the standard, but not having it will break at least ten millions files on just GitHub alone.

https://github.com/search?q=%22%23pragma+once%22+language%3AC%2B%2B+&type=code

It is so widely used that should be considered as a standard by itself.

The edge case is nobody's problem.

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

Successfully merging this pull request may close these issues.

2 participants