LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] gcc and printf style functions

[ILUG] gcc and printf style functions

kevin lyda kevin+dated+1110372506.52995e at ie.suberic.net
Fri Mar 4 12:48:07 GMT 2005


i'm using the sqlite library for a project.  one way to execute sql
calls is to use this function:

    int sqlite_exec_printf(sqlite *db,
                           char *sqlfmt,
                           int (*xCallback)(void*,int,char**,char**),
                           void *pArg,
                           char **errmsg,
                           ...);

with gcc you can tell the compiler and it can let you know if there's
a problem when that function is called.  so if the sqlite.h proto type
for this function was defined with that attribute it would give those
warnings for it.

    int sqlite_exec_printf(sqlite *db,
                           char *sqlfmt,
                           int (*xCallback)(void*,int,char**,char**),
                           void *pArg,
                           char **errmsg,
                           ...)  __attribute__((format(printf, 2, 6)));

that says that this function has a format string that uses a printf
style.  the format string is the second arg; the args to it begin at arg
6.

however.  there's a flaw.  sqlite_exec_printf()'s sqlfmt string has two
additional % escapes: %q and %Q.  they're like %s except that they
escape the string for sql (%q) and enclose it in single quotes (%Q).

i've read through the gcc docs and as far as i can see, i'd need to
change gcc in order to support new % format codes.  am i missing
something?

kevin

-- 
kevin lyda ~ dems for torture: salazar(co/10) landrieu(la/08) pryor(ar/08)
kevin at ie.suberic.net ~ nelson(fl/06) nelson(ne/06) lieberman(ct/06) 2/2/04
  Those who refuse to raise their voices against something as clearly evil
  as torture are enablers, if not collaborators.  --Bob Herbert, 2/11/04



More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell