[ccan] Valgrind + tests

Rusty Russell rusty at rustcorp.com.au
Wed Mar 25 11:15:41 EST 2009


On Tuesday 24 March 2009 23:18:25 Tim Post wrote:
> Hi,
> 
> On Tue, 2009-03-24 at 23:00 +1030, Rusty Russell wrote:
> 
> > Sure.  Or you can submit something that uses it, and it'll break my compile
> > (-Wundef) and I'll update config.h automatically :)
> > 
> 
> Can you please explain the sanity of using -Wundef when knowingly using
> something that explicitly points to (and encourages modification of)
> config.h?
> 
> If HAVE_VALGRIND_VALGRIND_H is not set, it would make little difference
> to someone using a module that they grabbed. However, someone using
> autotools would have this on or off depending on what configure found.
> 
> Or am I missing something? Quite possibly, I am :)

OK, it works like this.  Instead of using the standard:

	#ifdef HAVE_FOO

CCAN modules use:

	#if HAVE_FOO

The C preprocessor treats unknown symbols as 0, so as long as the convention
is "#define HAVE_FOO 1", these two are equivalent.

*Except* that I compile here with -Wundef -Werr: -Wundef warns about undefined
preprocessor symbols, and -Werr makes sure I notice it by erroring out.  That
means that when someone makes up a new HAVE_ symbol and I am going to spot it
and figure out whether I should set it or not.

It avoids the classic error where you miss new features simply because you
didn't update config.h

Hope that clarifies?
Rusty.



More information about the ccan mailing list