4 ms·
It may be widely supported but it's also nonstandard. You also have to use include guards anyway, so it's best to avoid pragma once altogether. And as the arti
by krapp 5y ago
It may be widely supported but it's also nonstandard. You also have to use include guards anyway, so it's best to avoid pragma once altogether.
And as the article mentions, that doesn't always solve the problem.
- jcelerier 5y ago> It may be widely supported but it's also nonstandard. by that logic no one should use python, ruby or rust because they don't have an iso or ecma standard either
- steveklabnik 5y ago(Ruby does have an ISO standard but it’s weird and nobody uses it.)
- jcelerier 5y agooh, TIL ! why wouldn't anyone use it ?
- steveklabnik 5y agoFor reference: https://www.iso.org/standard/59579.html https://www.iso.org/standard/59579.html This work happened in 2009. It was originally based on Ruby 1.8.7, the final draft was completed in 2010, and didn't cover the full standard library at the time. Took two more years to get through ISO. If you don't have an encyclopedic remembering of Ruby version releases, when that draft was complete, the current released version of Ruby was 1.9.2. Ruby underwent huge changes between 1.8.7 and 1.9.2; many other languages would have characterized it as a major version change at the time; Ruby didn't follow semver back then. So basically, it was already out of date well before it was final, and never was updated. So it's really irrelevant today. Why did this even happen? Well, supposedly there are some requirements for Japan government work that require a spec, and so a spec was produced. That's my recollection, anyway.
- krapp 5y agoI wasn't making a general statement about software standards but one specific to C/C++ preprocessor directives.
- jcelerier 5y agobut "standards" is a general statement in itself ; you can't dissociate the word from the whole ISO process in this context
- account42 5y agoName one C++ compiler that keeps up with C++ standards but does not provide #pragma once.
- tlb 5y agoI've been living on the edge using only #pragma once for several years and haven't regretted it. According to this support table, it's pretty widely supported these days: https://en.wikipedia.org/wiki/Pragma_once#Portability https://en.wikipedia.org/wiki/Pragma_once#Portability