Alexandre Julliard : crypt32/tests: Avoid sizeof in traces.

David Laight david at l8s.co.uk
Sat Aug 26 03:11:42 CDT 2006


On Fri, Aug 25, 2006 at 02:18:49PM -0700, Dan Kegel wrote:
> On 8/25/06, Alexandre Julliard <julliard at winehq.org> wrote:
> >> Just so I know, what is the warning? Does sizeof() return
> >> a 64-bit integer on those platforms?
> >
> >Not on 32-bit platforms, but it's defined as long instead of int so we
> >still get a printf format warning.
> 
> The incredibly ugly solution I've used in the past is
> 
> // printf macros for size_t, in the style of inttypes.h
> #ifdef _LP64
> #define __PRIS_PREFIX "z"
> #else
> #define __PRIS_PREFIX
> #endif
> #define PRIuS __PRIS_PREFIX "u"
> 
> and then
>  printf("size is %" PRIuS "\n", sizeof(foo));
> 
> Much nicer just to avoid using size_t in printf's if you can.

That doesn't help for the case:
	char xxx[...]
	...
	printf("%.*s", sizeof xxx, xxx);
since the argument for '*' has to be of type 'int'.
Here you have to have the (int) cast, directly of maybe via:
#define isizeof (void)sizeof

	David

-- 
David Laight: david at l8s.co.uk



More information about the wine-devel mailing list