News for hackers. Stuff that matters.
Re:New C features in GCC 13 by dxuh on Thursday May 04, 2023 @09:05AM (#35814635)
There is this guideline of "Almost Always Auto" (https://herbsutter.com/2013/08/12/gotw-94-solution-aaa-style...) and I have been following it for yeears both in my job and my personal projects and I have never been very confused by it or had any sort of bug because of it. I felt very reluctant about using it at all for quite a while myself, but in practice it just makes stuff easier and more obvious. A huge reason it's useful in C++ is generic code (stuff that depends on template parameters or has many template parameters) or deeply nested stuff (typing std::unordered_map<std::string, MyGreatObject::SomeValue>::iterator gets annoying), but it's nice almost everywhere. Most types are repeated and getting rid of those repetitions makes refactorings a lot easier and gets rid of some source of bugs. For example sometimes you forget to change all the relevant types from uint32_t to uint64_t when refactoring some value and stuff breaks weirdly (of course your compiler should warn on narrowing conversions, but just to illustrate the point, because it is very real).
Re:New C features in GCC 13 by pmarin on Thursday May 04, 2023 @09:48AM (#35815270)
>For example sometimes you forget to change all the relevant types from uint32_t to uint64_t when refactoring some value and stuff breaks weirdly

Use size_t

Re:New C features in GCC 13 by KerrAvon on Thursday May 04, 2023 @12:44PM (#35818335)
`size_t` may not be helpful. You can argue that some other specific typedef should have been used in this case, but it's kind of water under the bridge already.
Re:New C features in GCC 13 by tom_ on Thursday May 04, 2023 @01:38PM (#35819248)
size_t is for object sizes. It might not be 64 bits.