6 ms·
#pragma once
by mc4ndr3 4y ago
#pragma once
- krapp 4y agoIt 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 4y 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 4y ago(Ruby does have an ISO standard but it’s weird and nobody uses it.)
- jcelerier 4y agooh, TIL ! why wouldn't anyone use it ?
- steveklabnik 4y 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 4y agoI wasn't making a general statement about software standards but one specific to C/C++ preprocessor directives.
- jcelerier 4y agobut "standards" is a general statement in itself ; you can't dissociate the word from the whole ISO process in this context
- account42 4y agoName one C++ compiler that keeps up with C++ standards but does not provide #pragma once.
- tlb 4y 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
- account42 4y agoNot standardizing #pragma once because of edge cases with with network and other esoteric filesystems when pretty much every C++ compiler implements #pragma once is really peak C++ committee bs. And it's not even like the C++ standard doesn't leave other edge case behavior undefined or implementation defined...
- ncmncm 4y agoFortunately there is no need to standardize it. Everybody implements it, and all the same way.