Expressions of other types may be explicitly converted to type string
by using a cast expression or by applying the special stringof
operator, which are equivalent in meaning:
s = (string)expression
s = stringof (expression
)
The stringof
operator binds very tightly to the operand on its right-hand side. Typically, parentheses are used to surround the expression for clarity, although they are not strictly necessary.
Any expression that is a scalar type such as a pointer or integer or a scalar array address may be converted to string. Expressions of other types such as void
may not be converted to string
. If you erroneously convert an invalid address to a string, the DTrace safety features will prevent you from damaging the system or DTrace, but you might end up tracing a sequence of undecipherable characters.