diff options
Diffstat (limited to 'intern/ghost/intern/GHOST_utildefines.h')
-rw-r--r-- | intern/ghost/intern/GHOST_utildefines.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/intern/ghost/intern/GHOST_utildefines.h b/intern/ghost/intern/GHOST_utildefines.h index f0ae6e12d3e..ff092099c7c 100644 --- a/intern/ghost/intern/GHOST_utildefines.h +++ b/intern/ghost/intern/GHOST_utildefines.h @@ -208,3 +208,32 @@ (void)0 /** \} */ + +/* -------------------------------------------------------------------- */ +/** \name String Macros + * \{ */ + +/* Macro to convert a value to string in the preprocessor: + * - `STRINGIFY_ARG`: gives the argument as a string + * - `STRINGIFY_APPEND`: appends any argument 'b' onto the string argument 'a', + * used by `STRINGIFY` because some preprocessors warn about zero arguments. + * - `STRINGIFY`: gives the argument's value as a string. */ + +#define STRINGIFY_ARG(x) "" #x +#define STRINGIFY_APPEND(a, b) "" a #b +#define STRINGIFY(x) STRINGIFY_APPEND("", x) + +/* generic strcmp macros */ +#if defined(_MSC_VER) +# define strcasecmp _stricmp +# define strncasecmp _strnicmp +#endif + +#define STREQ(a, b) (strcmp(a, b) == 0) +#define STRCASEEQ(a, b) (strcasecmp(a, b) == 0) +#define STREQLEN(a, b, n) (strncmp(a, b, n) == 0) +#define STRCASEEQLEN(a, b, n) (strncasecmp(a, b, n) == 0) + +#define STRPREFIX(a, b) (strncmp((a), (b), strlen(b)) == 0) + +/** \} */ |