Re: newbie libpq question...
От | Edmund Bacon |
---|---|
Тема | Re: newbie libpq question... |
Дата | |
Msg-id | 4190E641.7070601@onesystem.com обсуждение исходный текст |
Ответ на | Re: newbie libpq question... (Doug Homoelle <homoelle@ll.mit.edu>) |
Список | 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@onesystem.com>
В списке pgsql-interfaces по дате отправления: