]> git.ozlabs.org Git - ccan/blobdiff - ccan/str/str.h
Add author and maintainer fields.
[ccan] / ccan / str / str.h
index f633bc757e1c15655b7a06cfcd21a08922bb4e2a..70fe26c74fad3905b3acf2efd8ac0b792ba766a5 100644 (file)
@@ -43,4 +43,16 @@ static inline bool strends(const char *str, const char *postfix)
 
        return streq(str + strlen(str) - strlen(postfix), postfix);
 }
+
+/**
+ * stringify - Turn expression into a string literal
+ * @expr: any C expression
+ *
+ * Example:
+ *     #define PRINT_COND_IF_FALSE(cond) \
+ *             ((cond) || printf("%s is false!", stringify(cond)))
+ */
+#define stringify(expr)                stringify_1(expr)
+/* Double-indirection required to stringify expansions */
+#define stringify_1(expr)      #expr
 #endif /* CCAN_STR_H */