C and C++ expressions

z/OS® Debugger allows evaluation of expressions in your test program. All expressions available in C and C++ are also available within z/OS Debugger except for the conditional expression (? :). That is, all operators such as +, -, %:, and += are fully supported with the exception of the conditional operator.

C and C++ language expressions are arranged in the following groups based on the operators they contain and how you use them:
  • Primary expression
  • Unary expression
  • Binary expression
  • Conditional expression
  • Assignment expression
  • Comma expression
  • lvalue
  • Constant

An lvalue is an expression representing a data object that can be examined and altered. For a more detailed description of expressions and operators, see the C and C++ Program Guides.

The semantics for C and C++ operators are the same as in a compiled C or C++ program. Operands can be a mixture of constants (integer, floating-point, character, string, and enumeration), C and C++ variables, z/OS Debugger variables, or session variables declared during a z/OS Debugger session. Language constants are specified as described in the C and C++ Language Reference publications.

The z/OS Debugger command DESCRIBE ATTRIBUTES can be used to display the resultant type of an expression, without actually evaluating the expression.

The C and C++ language does not specify the order of evaluation for function call arguments. Consequently, it is possible for an expression to have a different execution sequence in compiled code than within z/OS Debugger. For example, if you enter the following in an interactive session:
int x;
int y;

x = y = 1;

printf ("%d %d %d%" x, y, x=y=0);
the results can differ from results produced by the same statements located in a C or C++ program segment. Any expression containing behavior undefined by ANSI standards can produce different results when evaluated by z/OS Debugger than when evaluated by the compiler.
The following examples show you various ways z/OS Debugger supports the use of expressions in your programs:
  • z/OS Debugger assigns 12 to a (the result of the printf()) function call, as in:
    a = (1,2⁄3,a++,b++,printf("hello world\n"));
  • z/OS Debugger supports structure and array referencing and pointer dereferencing, as in:
    league[num].team[1].player[1]++;
    league[num].team[1].total += 1;
    ++(*pleague);
  • Simple and compound assignment is supported, as in:
    v.x = 3;
    a = b = c = d = 0;
    *(pointer++) -= 1;
  • C and C++ language constants in expressions can be used, as in:
    *pointer_to_long = 3521L = 0x69a1;
    float_val = 3e-11 + 6.6E-10;
    char_val = '7';
  • The comma expression can be used, as in:
    intensity <<= 1, shade * increment, rotate(direction);
    alpha = (y>>3, omega % 4);
  • z/OS Debugger performs all implicit and explicit C conversions when necessary. Conversion to long double is performed in:
    long_double_val = unsigned_short_val;
    long_double_val = (long double) 3;

Refer to the following topics for more information related to the material discussed in this topic.