[sane-devel] maximum image size for a scan for Canon pixma backend

Eddy De Greef eddy_de_greef at scarlet.be
Sun Jan 2 19:46:35 UTC 2011


On 01-01-11 00:49, Gernot Hassenpflug wrote:
> I had a report that %lu might be better than %llu for the debug
> statements, so I would like to confirm that %llu was not a typing
> error? Should I use %llu or %lu for the debug statements when uint64_t
> is the declared type?

Hi Gernot,

on a 32-bit platform, uint64_t is a "long long unsigned int" and 
therefore, %llu should be used in printf. On a 64-bit platform, however, 
uint64_t is (usually) a "long unsigned int", requiring %lu as format 
specifier.

These fixed-size types are part of the C99 standard, and to solve the 
ambiguity problem, they have also introduced some portable printf format 
macros in inttypes.h. The one that you need here is PRIu64, i.e. 
something like

   PDBG(pixma_dbg(4, "*calc_raw_width***** width %lu extended by %lu and 
rounded to %u *****\n", param->w, param->xs, raw_width));

should be written as

   PDBG(pixma_dbg(4, "*calc_raw_width***** width "PRIu64" extended by 
"PRIu64" and rounded to %u *****\n", param->w, param->xs, raw_width));

in order to be fully portable (provided that the compiler supports C99).
You'll also have to include <inttypes.h>, obviously (e.g. in pixma.h):

#ifdef HAVE_INTTYPES_H
# include <inttypes.h>		/* available in ISO C99 */
#endif /* HAVE_INTTYPES_H */

Best regards,
Eddy



More information about the sane-devel mailing list