Menu

Stringize operator

Cyder

Stringize Operator

Commonly known as the # (Hash) operator, it can be used, to transform a macro function argument into a string.
When using this operator, please not that the parameter will not be expanded before stringization (as per the c11 standard).

The following example show, that STRINGIZE will not expand "foo" before stringification, but STRINGIZE_2 will, because "foo" is expanded, when being inserted as a parameter for STRINGIZE

#define STRINGIZE(x) #x
#define STRINGIZE_2(x) STRINGIZE(x)
#define foo 42

STRINGIZE(foo)   // Expands to ["foo"]
STRINGIZE_2(foo) // Expands to ["42"]

s.a. [Bracket notation]


Related

Wiki: Bracket notation
Wiki: Token concat

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.