]> git.ozlabs.org Git - ccan/commitdiff
configurator: define HAVE_CCAN.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 14 Feb 2012 09:34:00 +0000 (20:04 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 14 Feb 2012 09:38:17 +0000 (20:08 +1030)
An interesting case came up with the tdb2 code in SAMBA recently.  It's a
public library, and it doesn't want to be dependent on CCAN, but the header
uses cast and typesafe_cb for extra type safety.

A good solution to this is to put dummy versions under !HAVE_CCAN.  Of course,
any CCAN config.h should define HAVE_CCAN.

config.h
tools/configurator/configurator.c

index 14788013deac11b6d738f308019044898034f73a..09b45824603dff28faef4364110ae0c5f3c8f1e0 100644 (file)
--- a/config.h
+++ b/config.h
@@ -7,6 +7,7 @@
 #define CCAN_COMPILER "cc"
 #define CCAN_CFLAGS "-g3 -ggdb -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wwrite-strings -DCCAN_STR_DEBUG=1"
 
 #define CCAN_COMPILER "cc"
 #define CCAN_CFLAGS "-g3 -ggdb -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wwrite-strings -DCCAN_STR_DEBUG=1"
 
+#define HAVE_CCAN 1
 #define HAVE_32BIT_OFF_T 1
 #define HAVE_ALIGNOF 1
 #define HAVE_ASPRINTF 1
 #define HAVE_32BIT_OFF_T 1
 #define HAVE_ALIGNOF 1
 #define HAVE_ASPRINTF 1
index e2c13b7e57161d004832e80af0a78b9a967f48d9..d5a23c2a8503ec39ffd38e842ec45baaf5a51637 100644 (file)
@@ -440,6 +440,8 @@ int main(int argc, const char *argv[])
        printf("#endif\n");
        printf("#define CCAN_COMPILER \"%s\"\n", argv[1]);
        printf("#define CCAN_CFLAGS \"%s\"\n\n", cmd + strlen(argv[1]) + 1);
        printf("#endif\n");
        printf("#define CCAN_COMPILER \"%s\"\n", argv[1]);
        printf("#define CCAN_CFLAGS \"%s\"\n\n", cmd + strlen(argv[1]) + 1);
+       /* This one implies "#include <ccan/..." works, eg. for tdb2.h */
+       printf("#define HAVE_CCAN 1\n");
        for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
                printf("#define %s %u\n", tests[i].name, tests[i].answer);
        printf("#endif /* CCAN_CONFIG_H */\n");
        for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
                printf("#define %s %u\n", tests[i].name, tests[i].answer);
        printf("#endif /* CCAN_CONFIG_H */\n");