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

Would a PR to switch to '#pragma once' be accepted? #858

Closed
cmorganBE opened this issue Apr 24, 2020 · 5 comments
Closed

Would a PR to switch to '#pragma once' be accepted? #858

cmorganBE opened this issue Apr 24, 2020 · 5 comments

Comments

@cmorganBE
Copy link

Would switch the #ifdef, #define, #endif entries to a single #pragma once at the top of each header file. #pragma once is widely supported at this point.

@xiaoxiang781216
Copy link
Contributor

I think it's hard to use this since:
1.NuttX need comatablie with C89 standard
2.#pragma once isn't defined in C standard
I also don't see the benefit to switch #ifndef/#define/#endif to #pragma once, do you have any particular reason?

@patacongo
Copy link
Contributor

No compiler dependencies are permitted directly anywhere in .c or .h files. #pragma may not be used there.

Compiler dependencies may be "indirectly" used if they are added to included/nuttx/compiler.h and a comon definition is provided for all tools. But even that use is discouraged. The OS should not, in general, depend on any property of any toolchain.

So, please, do not consider adding #pragma to any source files.

@cmorganBE
Copy link
Author

@xiaoxiang781216 just seeing a lot of complex header protection defines that someone has to put together (or script) that would go away.

@patacongo I appreciate that, normally I wouldn't advocate for a pragma as they are compiler implementation specific. It's too bad that it hasn't made its way into the language standard proper yet. It's been supported by basically all compilers for a dozen years now.

If, at some point, an exception would be made for this particular pragma, let me know!

@patacongo
Copy link
Contributor

No worth it. There is no real benefit and a very, very big downside. We must not introduce ANY compiler dependencies in the source code. We have followed that rule for a dozen years and it will not change now.. Let's not consider this.

@patacongo
Copy link
Contributor

patacongo commented Apr 24, 2020

Very bad idea. There is ABSOLUTELY not good reason to do this other than your personal preference which does not carry any weight in this.

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

No branches or pull requests

3 participants