To me it doesn't read like fascist garbage; it reads like a list of reminders by the author for the author.
Types: On ARM, char is signed unless declared unsigned. On Intel, char is unsigned unless declared signed. Either way it is 8 Bit, and so is UTF-8. I have to agree that types, even if equivalent, should convey intention, if only for the benefit of maintenance. Then again, the elegance of C is that it has only about 20 keywords, from which you can build anything but self-referential structs. I like to keep things small and simple, but I trust the compiler to optimize human maintainable code.
I'll use long and short where I need 32 and 16 Bit types, and int where size doesn't matter and byte should be enough and I trust the compiler to put it in a register only. Most for loops, for example. I know int is long these days; I don't care. The compiler should be free to use as int whatever the CPU is most comfortable with, and that is what I use it for.
I may be persuaded to use int32_t for short, but I really see no advantage in it. (I really wouldn't mind a byte keyword to supplement char, if only so the strlen of a character array can intuitively reflect something other than the number of bytes. But that is basically syntactic sugar, and I should watch my weight.)
10 comments
2 u/svipbo 08 Jan 2016 21:16
I always use
-O0because I got sick of gettingvalue optimized outingdb.edit: most of this article is fascist garbage, I'd take it all with a pinch of salt
3 u/weezkitty 09 Jan 2016 01:49
I see "C" what you mean. The never use this, never use that garbage.
Every tool has it's uses and you should use the tools available to you where appropriate
0 u/clickbot 09 Jan 2016 11:33
-Os; everything else is snake water.To me it doesn't read like fascist garbage; it reads like a list of reminders by the author for the author.
Types: On ARM,
charis signed unless declared unsigned. On Intel,charis unsigned unless declared signed. Either way it is 8 Bit, and so is UTF-8. I have to agree that types, even if equivalent, should convey intention, if only for the benefit of maintenance. Then again, the elegance of C is that it has only about 20 keywords, from which you can build anything but self-referential structs. I like to keep things small and simple, but I trust the compiler to optimize human maintainable code.I'll use
longandshortwhere I need 32 and 16 Bit types, andintwhere size doesn't matter and byte should be enough and I trust the compiler to put it in a register only. Mostforloops, for example. I knowintis long these days; I don't care. The compiler should be free to use asintwhatever the CPU is most comfortable with, and that is what I use it for.I may be persuaded to use
int32_tfor short, but I really see no advantage in it. (I really wouldn't mind abytekeyword to supplementchar, if only so the strlen of a character array can intuitively reflect something other than the number of bytes. But that is basically syntactic sugar, and I should watch my weight.)Return types:
"Do not do this." No shit! How about a gore warning? Children might be reading this! Horrible!
All in all, a useable write-up, though I should expect most people here to be already familiar with the content.
0 u/Atarian 09 Jan 2016 10:04
Well, I write code that I cross compile on the Atari ST so this doesn't apply to me anyway, but "never use char"?