Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/crypto/external/bsd/netpgp/dist/src/lib



On Fri, Jun 25, 2010 at 08:40:26PM +0000, Christos Zoulas wrote:
> In article <20100625183016.AC0BE175DF%cvs.netbsd.org@localhost>,
> Alistair G. Crooks <source-changes-d%NetBSD.org@localhost> wrote:
> >-=-=-=-=-=-
> >
> >Module Name: src
> >Committed By:        agc
> >Date:                Fri Jun 25 18:30:16 UTC 2010
> >
> >Modified Files:
> >     src/crypto/external/bsd/netpgp/dist/src/lib: misc.c
> >
> >Log Message:
> >Fix build problems on LP64 platforms - thanks to Paul Goyette for the nudge.
> 
> That should be %zu really; it is more readable.

%zu is more readble, but it's C99, and even some C99 implementations
don't define it (I have in my mind Microsoft from the time that I brought
up the iSCSI target on Windows, but I may be wrong there)

The following quote is apt:

        C99 adds a 'z' modifier specifically for size_t:

        printf("Total buffer size: %zu bytes\n", buffer_size);

        but many printf implementations don't support it. (Even if your
        compiler supports C99 and defines __STDC_VERSION__ appropriately,
        that's not, practically speaking, a guarantee that the library also
        conforms to C99.)

        Even in C99, the "%lu" method will work unless size_t is bigger than
        unsigned long *and* the value being printed exceeds ULONG_MAX, which
        is unlikely to happen in practice.

        --
        Keith Thompson (The_Other_Keith) kst-u%mib.org@localhost 
<http://www.ghoti.net/~kst>
        San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>

referenced in:

        
http://bytes.com/topic/c/answers/221867-portable-way-printf-size_t-instance

Oh, and yes, this is not a "we need to conform to c89 as LCD" post -
this is 2010 after all - it's an "I want netpgp to be as portable as
possible" post.

Regards,
Alistair


Home | Main Index | Thread Index | Old Index