Debugging with GDB (February 2008)

Table Of Contents
84 Debugging with GDB
9.4.1 C and C++
Since C and C++ are so closely related, many features of GDB apply to both languages.
Whenever this is the case, we discuss those languages together.
The C++ debugging facilities are jointly implemented by the C++ compiler and GDB.
Therefore, to debug your C++ code effectively, you must compile your C++ programs with
a supported C++ compiler, such as gnu g++, or the HP ANSI C++ compiler (aCC).
For best results when using gnu C++, use the stabs debugging format. You can select
that format explicitly with the g++ command-line options -gstabs or -gstabs+’. Refer
to section “Options for Debugging Your Program or gnu CC” in Using gnu CC, for more
information.
9.4.1.1 C and C++ operators
Operators must be defined on values of specific types. For instance, + is defined on
numbers, but not on structures. Operators are often defined on groups of types.
For the purposes of C and C++, the following definitions hold:
Integral types include int with any of its storage-class specifiers; char; enum; and, for
C++, bool.
Floating-point types include float, double, and long double (if supported by the
target platform).
Pointer types include all types defined as (type *).
Scalar types include all of the above.
The following operators are supported. They are listed here in order of increasing prece-
dence:
, The comma or sequencing operator. Expressions in a comma-separated list are
evaluated from left to right, with the result of the entire expression being the
last expression evaluated.
= Assignment. The value of an assignment expression is the value assigned. De-
fined on scalar types.
op = Used in an expression of the form a op = b , and translated to a = a op b . op =
and = have the same precedence. op is any one of the operators |, ^, &, <<, >>,
+, -, *, /, %.
?: The ternary operator. a ? b : c can be thought of as: if a then b else c. a
should be of an integral type.
|| Logical or. Defined on integral types.
&& Logical and. Defined on integral types.
| Bitwise or. Defined on integral types.
^ Bitwise exclusive-or. Defined on integral types.
& Bitwise and. Defined on integral types.