Boost logo

Boost :

From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2008-02-08 11:38:55


Colin Caughie wrote:
>> From what I can see so far, using this library is not going to be a
>> compelling alternative to the concise
>>
>> #include <syslog.h>
>> syslog(LOG_WARN,"Blob %d failed to %s",n,x);
>
> Yeah, we used to do that. Once you've had a few crashes due to passing the wrong
> argument types in the variable argument list, that _only_ happen when you hit
> the error condition that that line is supposed to help you diagnose,
> Boost.Logging looks very compelling indeed... :)

You need a compiler that type-checks printf-like function calls:

in /usr/include/sys/syslog.h:
extern void syslog (int __pri, __const char *__fmt, ...)
      __attribute__ ((__format__(__printf__, 2, 3)));

test.c:
#include <syslog.h>
void f(char* s) {
   syslog(LOG_INFO,"Foo %d",s);
}

$ gcc -W -Wall -c /tmp/test.c
/tmp/test.c: In function ‘f’:
/tmp/test.c:3: warning: format ‘%d’ expects type ‘int’, but argument 3
has type ‘char *’

Phil.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk