128
Chapter 6. Extensions to the C Language Family
This is quite different from what
would do--that would convert 1 to floating point and
(int)f = 1
store it. Rather than cause this inconsistency, we think it is better to prohibit use of
on a cast.
&
If you really do want an
pointer with the address of
, you can simply write
.
int *
f
(int *)&f
6.8. Conditionals with Omitted Operands
The middle operand in a conditional expression may be omitted. Then if the first operand is nonzero,
its value is the value of the conditional expression.
Therefore, the expression
x ? : y
has the value of
if that is nonzero; otherwise, the value of
.
x
y
This example is perfectly equivalent to
x ? x : y
In this simple case, the ability to omit the middle operand is not especially useful. When it becomes
useful is when the first operand does, or may (if it is a macro argument), contain a side effect. Then
repeating the operand in the middle would perform the side effect twice. Omitting the middle operand
uses the value already computed without the undesirable effects of recomputing it.
6.9. Double-Word Integers
ISO C99 supports data types for integers that are at least 64 bits wide, and as an extension GCC sup-
ports them in C89 mode and in C++. Simply write
for a signed integer, or
long long int
unsigned
for an unsigned integer. To make an integer constant of type
, add
long long int
long long int
the suffix
to the integer. To make an integer constant of type
, add the
LL
unsigned long long int
suffix
to the integer.
ULL
You can use these types in arithmetic like any other integer types. Addition, subtraction, and bitwise
boolean operations on these types are open-coded on all types of machines. Multiplication is open-
coded if the machine supports fullword-to-doubleword a widening multiply instruction. Division and
shifts are open-coded only on machines that provide special support. The operations that are not open-
coded use special library routines that come with GCC.
There may be pitfalls when you use
types for function arguments, unless you declare
long long
function prototypes. If a function expects type
for its argument, and you pass a value of type
int
, confusion will result because the caller and the subroutine will disagree about the
long long int
number of bytes for the argument. Likewise, if the function expects
and you pass
long long int
. The best way to avoid such problems is to use prototypes.
int
6.10. Complex Numbers
ISO C99 supports complex floating data types, and as an extension GCC supports them in C89 mode
and in C++, and supports complex integer data types which are not part of ISO C99. You can declare
complex types using the keyword
. As an extension, the older GNU keyword
_Complex
__complex__
is also supported.
For example,
declares
as a variable whose real part and imaginary part are
_Complex double x;
x
both of type
.
declares
to have real and imaginary parts of type
double
_Complex short int y;
y
; this is not likely to be useful, but it shows that the set of complex types is complete.
short int
Need help?
Do you have a question about the ENTERPRISE LINUX 3 - USING GCC and is the answer not in the manual?
Questions and answers