X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fcompiler%2Fcompiler.h;h=242ef84d133ddb65ea378bdfcc6585a7f46d7bd8;hp=be229670fd127a5f89e9e9bc6b14e4a7cc48ddce;hb=18636637ee013ef828cb04b2b7bb4a4922324475;hpb=b1801a00c945b67d8c218edd9e13dc483a60ac70 diff --git a/ccan/compiler/compiler.h b/ccan/compiler/compiler.h index be229670..242ef84d 100644 --- a/ccan/compiler/compiler.h +++ b/ccan/compiler/compiler.h @@ -10,10 +10,10 @@ * It is usually used on logging or error routines. * * Example: - * void COLD_ATTRIBUTE moan(const char *reason) - * { - * fprintf(stderr, "Error: %s (%s)\n", reason, strerror(errno)); - * } + * static void COLD_ATTRIBUTE moan(const char *reason) + * { + * fprintf(stderr, "Error: %s (%s)\n", reason, strerror(errno)); + * } */ #define COLD_ATTRIBUTE __attribute__((cold)) #else @@ -23,13 +23,14 @@ #if HAVE_ATTRIBUTE_PRINTF /** * PRINTF_ATTRIBUTE - a function takes printf-style arguments - * nfmt: the 1-based number of the function's format argument. - * narg: the 1-based number of the function's first variable argument. + * @nfmt: the 1-based number of the function's format argument. + * @narg: the 1-based number of the function's first variable argument. * * This allows the compiler to check your parameters as it does for printf(). * * Example: - * void PRINTF_ATTRIBUTE(2,3) my_printf(char *prefix, char *format, ...); + * void PRINTF_ATTRIBUTE(2,3) my_printf(const char *prefix, + * const char *fmt, ...); */ #define PRINTF_ATTRIBUTE(nfmt, narg) \ __attribute__((format(__printf__, nfmt, narg))) @@ -58,18 +59,14 @@ * the compiler that if it is unused it need not emit it into the source code. * * Example: - * // With some config options, this is unnecessary. - * static UNNEEDED_ATTRIBUTE int counter; - * ... - * #ifdef DEBUG - * counter++; - * #endif - * ... - * // With some config options, this is unnecessary. - * static UNNEEDED_ATTRIBUTE int add_to_counter(int add) - * { - * counter += add; - * } + * // With some preprocessor options, this is unnecessary. + * static UNNEEDED_ATTRIBUTE int counter; + * + * // With some preprocessor options, this is unnecessary. + * static UNNEEDED_ATTRIBUTE void add_to_counter(int add) + * { + * counter += add; + * } */ #define UNNEEDED_ATTRIBUTE __attribute__((unused)) @@ -117,7 +114,7 @@ * const char *greek_name(enum greek greek); * * // Inline version. - * static inline _greek_name(enum greek greek) + * static inline char *_greek_name(enum greek greek) * { * switch (greek) { * case ALPHA: return "alpha";