6 * compiler - macros for common compiler extensions
8 * Abstracts away some compiler hints. Currently these include:
10 * For functions not called in fast paths (aka. cold functions)
12 * For functions which take printf-style parameters.
13 * - IDEMPOTENT_ATTRIBUTE
14 * For functions which return the same value for same parameters.
16 * For functions and variables which must be emitted even if unused.
17 * - UNNEEDED_ATTRIBUTE
18 * For functions and variables which need not be emitted if unused.
19 * - IS_COMPILE_CONSTANT
20 * For using different tradeoffs for compiletime vs runtime evaluation.
22 * Licence: LGPL (3 or any later version)
23 * Author: Rusty Russell <rusty@rustcorp.com.au>
26 * #include <ccan/compiler/compiler.h>
30 * // Example of a (slow-path) logging function.
31 * static int log_threshold = 2;
32 * static void COLD_ATTRIBUTE PRINTF_ATTRIBUTE(2,3)
33 * logger(int level, const char *fmt, ...)
37 * if (level >= log_threshold)
38 * vfprintf(stderr, fmt, ap);
42 * int main(int argc, char *argv[])
45 * logger(3, "Don't want %i arguments!\n", argc-1);
51 int main(int argc, char *argv[])
53 /* Expect exactly one argument */
57 if (strcmp(argv[1], "depends") == 0) {