From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,e4984c6f2b7e463 X-Google-Attributes: gid1164f8,public From: pmontgom@cwi.nl (Peter L. Montgomery) Subject: Re: long long in Digital Unix Date: 1997/08/17 Message-ID: #1/1 X-Deja-AN: 264730339 Sender: news@cwi.nl (The Daily Dross) References: Organization: CWI, Amsterdam Newsgroups: comp.sys.dec In article Dirk Grunwald writes: >I'm porting a program that makes extensive use of 'long long' >under Solaris. They intend it to mean 64 bit longs. >The Digital Unix 'printf' and and 'scanf' don't grok the '%lld' >specification for a long long value. ANyone know of a way >around thsi w/o #ifdef'ing all the instances? For printf, write your own conversion. 2^63 < 10^19, so a signed 64-bit integer needs at most a sign, 19 digits and a null terminator. Then typedef char llbuf_t[21]; extern char* llout(long long, llbuf_t); llout should output its first argument into the buffer given by the second argument, and return a pointer to the first character used in the buffer. If a printf outputs three long longs n1, n2, n3, then you use llbuf_t n1buf, n2buf, n3buf; printf("n1 = %s, n2 = %s, n3 = %s\n", llout(n1, n1buf), llout(n2, n2buf), llout(n3, n3buf)); A similar design applies to any user-defined type which printf does not directly support. Scanf is harder. You can use the %s format with a maximum length, to ensure your buffer does not overflow. Then convert the data yourself. -- Peter L. Montgomery pmontgom@cwi.nl San Rafael, California A mathematician whose age has doubled since he last drove an automobile.