3 ms·
Amazing how hard some people try to avoid the obviously correct and portable "#pragma once".
by quotemstr 2y ago
Amazing how hard some people try to avoid the obviously correct and portable "#pragma once".
- uecker 2y agoIt is neither portable nor obviously correct.
- quotemstr 2y agoYes, it's both. It works fine in real world million line codebases. I have never, not once, seen a bug or portability issue caused by it. I have seen multiple header guard macro names collide. Eschewing pragma once these days is pure ignorance and superstition --- then again, so is writing new code in C at all.
- iainmerrick 2y agoYep, header guard name collisions, and also typos in header guards so they don’t work as intended.
- uecker 2y agoThis good for you, other people reported problems with pragma once. And I think C is one of the better languages you could use to write code today. Also from the programs I use daily, the more stable and reliable ones tend to be written in C.
- cozzyd 2y agofor me it's mostly muscle memory that takes a few seconds at the beginning of a file. i#ifndef __foo_h <escape>yyp:s/ifndef/define/<enter>o<enter>#endif<escape>