Re: [Hamlib-developer] Minor cleanup needed
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Nate B. <n0...@n0...> - 2025-06-24 18:26:57
|
* On 2025 24 Jun 12:16 -0500, "Christoph v. Wüllen" wrote: > > > > The size_t(3) man page states size_t is an unsigned integer and here in > > rig.c the 'needed' variable is of the size_t type. Thus 'u' should be > > correct. > > > This is (only) true for a specific system. What the size_t type > is all about is that it can be different on different systems. Sure, but as I understand from this Stack Overflow thread: https://stackoverflow.com/q/940087 This is exactly the intent of the 'z' length modifier which was introduced in C99. The discussion also concludes that the 'u' conversion specifier is correct for a size_t variable. > Do not draw conclusions for coding from a specific system. > My advice is to use > %ul and type-cast the argument to unsigned long, this should > work (as of now) on any system I know of. That thread gives your example for C90. As I agree with others that it should be standard practice to target C11/C17, I think we simply need to stop coding against C90 and move forward. 73, Nate -- "The optimist proclaims that we live in the best of all possible worlds. The pessimist fears this is true." Web: https://www.n0nb.us Projects: https://github.com/N0NB GPG fingerprint: 82D6 4F6B 0E67 CD41 F689 BBA6 FB2C 5130 D55A 8819 |