Path: utzoo!utgpu!water!watmath!clyde!bellcore!faline!ulysses!allegra!princeton!udel!gatech!hao!ames!amdcad!sun!pitstop!sundc!seismo!uunet!nuchat!flatline!sugar!peter From: peter@sugar.UUCP Newsgroups: comp.sources.bugs Subject: Re: shar Keywords: printf word size null pointer Message-ID: <1414@sugar.UUCP> Date: 24 Jan 88 07:40:22 GMT References: <965@ssc.UUCP> <7098@brl-smoke.ARPA> Organization: Sugar Land UNIX - Houston, TX Lines: 21 Posted: Sun Jan 24 02:40:22 1988 In article <7098@brl-smoke.ARPA>, gwyn@brl-smoke.ARPA (Doug Gwyn ) writes: > In article <965@ssc.UUCP> kent@ssc.UUCP (Kent) writes: > >Somebody elsewhere (in comp.lang.c, maybe) was annoyed about types > >like time_t, which pretend to improve portability via data hiding, but > >actually make a mess, since we need to know the underlying type anyway. > For printf purposes, so long as it's known to be an integral type, > simply always cast the argument to long and use %ld format. Or run something like this sucker to create a macro file: int test; test = (time_t)1.05; if(test == (time_t)1) printf("#define CVT_time_t \"%s\"\n", (sizeof(time_t)==sizeof(long)) ? "%ld" : "%d"); else printf("#define CVT_time_t \"%s\"\n", (sizeof(time_t)==sizeof(float)) ? "%f" : "%lf"); -- -- Peter da Silva `-_-' ...!hoptoad!academ!uhnix1!sugar!peter -- Disclaimer: These U aren't mere opinions... these are *values*.