Device Monitoring Studio - Monitor, log and analyze data coming through PC ports and connections
Download Device Monitoring Studio Hide this button

$print Directive

Syntax:

$print(var-name-string-expression, var-value-expression);

The first expression must be a constant string expression and serves as a pseudo-field name. This name is displayed in the Structure View data visualizer. It is also added as a real field into the current scope and may be later referenced in expressions. The second expression is a field's value. It may be either a constant expression or a non-const expression, that will be evaluated at run time.

struct A
{
    int a;
    int b;
    $print("double_a", a * 2);
    $print("a/b", double(a) / b);
};

Both $print directives in the example above introduce new fields into the current scope (of struct A), but only the first one may be referenced in expressions, because the second one has incorrect name. So, it's OK to use any name for the first argument, but only syntactically correct ones may be referenced in expressions.