X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 226A73A3CBC for ; Tue, 9 Nov 2004 15:46:13 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60995-06 for ; Tue, 9 Nov 2004 15:46:07 +0000 (GMT) Received: from happy.onesystem.ca (happy.onesystem.ca [205.206.61.17]) by svr1.postgresql.org (Postfix) with ESMTP id 567AD3A3C5D for ; Tue, 9 Nov 2004 15:46:10 +0000 (GMT) Received: from elb_lx.onesystem.ca ([10.1.1.50]) by happy.onesystem.ca with asmtp (Exim 4.14) id 1CRYCA-0002PA-Jt; Tue, 09 Nov 2004 08:46:10 -0700 Message-ID: <4190E641.7070601@onesystem.com> Date: Tue, 09 Nov 2004 08:46:09 -0700 From: Edmund Bacon User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Cc: Doug Homoelle Subject: Re: newbie libpq question... References: <1099953369.2819.11.camel@> <20041108182155.086d9d58.darcy@druid.net> <1100012089.2819.13.camel@ > In-Reply-To: <1100012089.2819.13.camel@ > Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/16 X-Sequence-Number: 5142 Doug Homoelle wrote: > That worked. I guess I would have expected an error if there was a type > mismatch, but like I said, my C is pretty rusty. > If you are using gcc you can add -Wformat to your compile options to have it report if your printf() arguments don't match the format specifier - I don't know if other compilers do this, or how to turn it on if they do. Note that for the compiler to know if your printf() arguments are correct, you have to supply the format string as a string literal to the call. As an example, see the following program: $ cat print.c #include int main(void) { const char *format = "d = %f\n"; int d = 0; printf(format, d); d = 1; printf("d = %f\n", d); return 0; } $ gcc -Wall -W print.c -o print print.c: In function `main': print.c:11: warning: double format, different type arg (arg 2) -- Edmund Bacon