markus.hoeni...@mhoenicka.de writes: > could you please clarify with a code snippet (or better yet, a patch) > what should be changed in the libdbi sources? Also, I take from [1] > that this is a GNU extension of C. Would other compilers like LLVM > complain about the suggested change?
It is a GNU extension, but it's not hard to hide it from non-GNU compilers. The Postgres project uses this extensively, and it's caught many a typo for us. (Of course, you need to have developers using gcc, or it doesn't help. But not everyone has to use it, as long as those who do use it will notice warnings.) Some relevant bits from the Postgres sources: #ifndef __GNUC__ #define __attribute__(_arg_) #endif /* * Set the format style used by gcc to check printf type functions. We really * want the "gnu_printf" style set, which includes what glibc uses, such * as %m for error strings and %lld for 64 bit long longs. But not all gcc * compilers are known to support it, so we just use "printf" which all * gcc versions alive are known to support, except on Windows where * using "gnu_printf" style makes a dramatic difference. Maybe someday * we'll have a configure test for this, if we ever discover use of more * variants to be necessary. */ #ifdef WIN32 #define PG_PRINTF_ATTRIBUTE gnu_printf #else #define PG_PRINTF_ATTRIBUTE printf #endif and here's a typical use: extern int pg_snprintf(char *str, size_t count, const char *fmt,...) /* This extension allows gcc to check the format string */ __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4))); Depending on your usage, you might not need the gnu_printf dance. regards, tom lane ------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter _______________________________________________ libdbi-devel mailing list libdbi-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libdbi-devel