Isn't %ld a long int whereas  %lld is a long long int?  The %I64d refers to
a 64-bit or long long int. Likewise, %llu denotes a long long unsigned int
or 64-bit unsigned int. If passing a long long int and using %ld, I would
expect GCC to give a warning bout possible loss of data.  That, or it
really should be %ld on both Windows and non-Windows platforms.

Both VS2010 and VS2012 support %lld and %llu so the if/else for %I64d is no
longer required for 64-bit integers unless using  a 6+ year old compiler.
 I assume VS2013 also supports %lld and %llu as well although I haven't
tested it yet since I don't believe it supports building Win XP apps or
Windows Server 2003 of which I still have a couple to support at work.

Jon Sonntag



On Thu, Mar 20, 2014 at 11:06 AM, Toralf Förster <[email protected]>wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> On 03/20/2014 02:15 AM, Charlie Fenton wrote:
> > Hi Toralf,
> >
> > For which OS are you running cppchek?  I ask because this item is
> OS-dependent:
> >> [clientgui/browser.cpp:749]: (warning) %I64d in format string (no. 1)
> requires '__int64 *' but the argument type is 'long *'.
> >
> > But the referenced code was:
> >> #ifdef _WIN32
> >>         "%I64d",
> >> #else
> >>         "%ld",
> >> #endif
> >>         &httponly
> >
> > Cheers,
> > --Charlie
> >
> Ick, ofc that's important: I do run a 32bit Gentoo Linux (stable)
>
> > On Mar 19, 2014, at 2:14 PM, Toralf Förster wrote:
> >
> > Running it against latest git tree brought up few things where at least
> these among them IMO are worth to be checked :
> >
> > [clientgui/browser.cpp:749]: (warning) %I64d in format string (no. 1)
> requires '__int64 *' but the argument type is 'long *'.
> > [db/boinc_db.cpp:61]: (error) Using 'memset' on struct that contains a
> 'std::vector'.
> > [dcapi/common/cfg-client.c:115]: (error) Uninitialized variable: tmp
> > [lib/mac/QMachOImageList.c:364]: (error) Uninitialized variable:
> elemCount
> > [lib/mac/QMachOImageList.c:365]: (error) Uninitialized variable: elemSize
> > [lib/procinfo_mac.cpp:119]: (warning) %ld in format string (no. 5)
> requires 'long *' but the argument type is 'unsigned long *'.
> > [samples/nvcuda/cuda.cpp:114]: (warning) %lf in format string (no. 1)
> requires 'double *' but the argument type is '$float *'.
> > [sched/target_batch.cpp:134]: (error) Width 256 given in format string
> (no. 1) is larger than destination buffer 'batch_str[256]', use %255s to
> prevent overflowing it.
> > [win_build/installerv2/redist/Windows/src/boinccas/password.cpp:120]:
> (error) Mismatching allocation and deallocation: pTRandomPwd
> > [zip/zip/unix/z_unix.c:760]: (error) mismatching number of '(' and ')'
> in this line: defined(__NETBSD__))
> >
> >
> >> _______________________________________________
> >> boinc_dev mailing list
> >> [email protected]
> >> http://lists.ssl.berkeley.edu/mailman/listinfo/boinc_dev
> >> To unsubscribe, visit the above URL and
> >> (near bottom of page) enter your email address.
> >>
> >
> >
>
> - --
> MfG/Sincerely
> Toralf Förster
> pgp finger print:1A37 6F99 4A9D 026F 13E2 4DCF C4EA CDDE 0076 E94E
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.22 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iF4EAREIAAYFAlMrEgkACgkQxOrN3gB26U410wD+IPvrcjJPqd0Z3+y//DoMamnL
> BTE107LhwiaQTwd5PKcA+QGbRwtn1RVXBAwFQx7dI2XM/nNi4kRQVKXQKFFo0ta6
> =6gyN
> -----END PGP SIGNATURE-----
> _______________________________________________
> boinc_dev mailing list
> [email protected]
> http://lists.ssl.berkeley.edu/mailman/listinfo/boinc_dev
> To unsubscribe, visit the above URL and
> (near bottom of page) enter your email address.
_______________________________________________
boinc_dev mailing list
[email protected]
http://lists.ssl.berkeley.edu/mailman/listinfo/boinc_dev
To unsubscribe, visit the above URL and
(near bottom of page) enter your email address.

Reply via email to