diff options
author | Fedja Beader <fedja@protonmail.ch> | 2025-04-08 01:40:03 +0200 |
---|---|---|
committer | Fedja Beader <fedja@protonmail.ch> | 2025-04-08 01:42:26 +0200 |
commit | a9669ebff8f317a29ad07bcd0701f8cf3e0587f8 (patch) | |
tree | 3f9b26b701d2240b7b6bc5c6ffc310b611ff2e67 /src/localconsts.h | |
parent | ae6a5dd611506122ccb2058235873391ca3d9978 (diff) | |
download | manaplus-logger.h_attribute_format.tar.gz manaplus-logger.h_attribute_format.tar.bz2 manaplus-logger.h_attribute_format.tar.xz manaplus-logger.h_attribute_format.zip |
So it seems that CILK PLUS either ignores the this argument of memberlogger.h_attribute_format
functions or already considers it on its own.
Besides.. is CILK PLUS even relevant today? Whatever..
Plus, deduplicate some more functions
..should this attribute be moved to its own file?
Diffstat (limited to 'src/localconsts.h')
-rw-r--r-- | src/localconsts.h | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/src/localconsts.h b/src/localconsts.h index 6a50a789f..fe53c590c 100644 --- a/src/localconsts.h +++ b/src/localconsts.h @@ -171,30 +171,37 @@ #define gnu_printf printf #endif // __clang__ +/* + * A_FORMAT_PRINTF: Proxy for printf-like attribute tagging, + * All argument positions start indexed by 1 + * + * isMember true if member function. The below will shift by one. + * fmtIndex: position of format string in argument list + * firstArgIndex: position of first optional argument to format. + */ +#ifdef BAD_CILKPLUS +#define A_FORMAT_PRINTF_SHIFT 0 +#else +#define A_FORMAT_PRINTF_SHIFT 1 +#endif +// idk how to clean this up #ifdef __GNUC__ #ifdef __OpenBSD__ - #define A_FORMAT_PRINTF(fmtIndex, firstArgIndex) \ - __attribute__((__format__(printf, (fmtIndex), (firstArgIndex)))) - #else // __OpenBSD__ - - #ifdef BAD_CILKPLUS - // This one is 0-indexed? - #define A_FORMAT_PRINTF(fmtIndex, firstArgIndex) \ - __attribute__((__format__(gnu_printf, \ - ((fmtIndex) - 1), \ - ((firstArgIndex)-1) \ - ))) - #else // BAD_CILKPLUS - #define A_FORMAT_PRINTF(fmtIndex, firstArgIndex) \ - __attribute__((__format__(gnu_printf, \ - (fmtIndex), \ - (firstArgIndex) \ - ))) - #endif // BAD_CILKPLUS - - #endif // __OpenBSD__ -#endif // __GNUC__ + #define A_FORMAT_PRINTF_FUNC printf + #else + #define A_FORMAT_PRINTF_FUNC gnu_printf + #endif +#else + #define A_FORMAT_PRINTF_FUNC gnu_printf +#endif + +#define A_FORMAT_PRINTF(isMember, fmtIndex, firstArgIndex) \ + __attribute__((__format__( \ + A_FORMAT_PRINTF_FUNC, \ + ((fmtIndex) + ((isMember) ? A_FORMAT_PRINTF_SHIFT : 0)), \ + ((firstArgIndex) + ((isMember) ? A_FORMAT_PRINTF_SHIFT : 0)) \ + ))) #ifdef ADVGCC |