bug? in turbo c++

Richard A. O'Keefe ok at goanna.cs.rmit.oz.au
Thu Mar 7 16:41:53 AEST 1991


In article <1991Mar6.173733.430 at unhd.unh.edu>, rg at msel.unh.edu (Roger Gonzalez) writes:
>     int     i;
>     long    j;

>         printf("oh crud: %x %10d %x\r", i, j, i);
> Is this a new ansi-ism?

Nope, that's the way it was back when 'long' became available on PDP-11s.
Always use "%d", "%x" and so on for "int".	(PDP-11: 2 == sizeof (int))
Always use "%ld", "%lx" and so on for "long".	(PDP-11: 4 == sizeof (long))
No need to worry about "char" or "short", as they promote to "int".

> Will this
> behavior change to what my Unix cc fingers expect if I set it to K&R?

This *IS* what UNIX cc compilers require.  You are confusing "machine
where sizeof (int) == sizeof (long)" with "UNIX machine".  'Tisn't so.
PDP-11s & Z8000s running UNIX had the same problem for the same reason.

-- 
The purpose of advertising is to destroy the freedom of the market.



More information about the Comp.lang.c mailing list