Newsgroups: comp.lang.c Path: utzoo!telly!problem!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Subject: Re: Style guides and portability Message-ID: <1991Jan15.170244.18394@druid.uucp> Organization: D'Arcy Cain Consulting, West Hill, Ontario References: <1991Jan13.182655.17672@athena.mit.edu> <10608@hydra.Helsinki.FI> Date: Tue, 15 Jan 91 17:02:44 GMT In article <10608@hydra.Helsinki.FI> Lars Wirzenius writes: >In article <1991Jan13.182655.17672@athena.mit.edu> scs@adam.mit.edu writes: >>P.S. The answer to "How do you print something declared with >>`int32 bigint;' ?" is that you have to abandon printf in favor of >>something you define, like "print32". I find this awkward, and >Is there any problem in using > printf("%ld", (long) bigint) >other than that it's clumsy? I'm currently writing code that has this problem. I have some types such as: typedef long TASK_ID; typedef int HANDLE; etc... where I may want to change the types in the future. I solved the printf problem by doing the following: #define f_TASK_ID "ld" #define f_HANDLE "d" ... printf("Current task is %5" f_TASK_ID " for handle %" f_HANDLE "\n", t, h); Now if I change the type I just change the corresponding define and re-compile. Of course it is even clumsier but I think it makes the changes easier to handle. -- D'Arcy J.M. Cain (darcy@druid) | D'Arcy Cain Consulting | There's no government West Hill, Ontario, Canada | like no government! +1 416 281 6094 |