From: | Edmund Bacon <ebacon(at)onesystem(dot)com> |
---|---|
To: | pgsql-interfaces(at)postgresql(dot)org |
Cc: | Doug Homoelle <homoelle(at)ll(dot)mit(dot)edu> |
Subject: | Re: newbie libpq question... |
Date: | 2004-11-09 15:46:09 |
Message-ID: | 4190E641.7070601@onesystem.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
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 <stdio.h>
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 <ebacon(at)onesystem(dot)com>
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2004-11-09 16:35:55 | Re: ecpg: using cursor returned from a stored function |
Previous Message | Doug Homoelle | 2004-11-09 14:54:49 | Re: newbie libpq question... |