Case Ranges; Cast To A Union Type - Red Hat ENTERPRISE LINUX 3 - USING GCC Using Instructions

Using the gnu compiler collection (gcc)
Hide thumbs Also See for ENTERPRISE LINUX 3 - USING GCC:
Table of Contents

Advertisement

136
You can also write a series of
subobject to initialize; the list is taken relative to the subobject corresponding to the closest surround-
ing brace pair. For example, with the
struct point ptarray[10] = { [2].y = yv2, [2].x = xv2, [0].x = xv0 };
If the same field is initialized multiple times, it will have value from the last initialization. If any
such overridden initialization has side-effect, it is unspecified whether the side-effect happens or not.
Currently, gcc will discard them and issue a warning.

6.23. Case Ranges

You can specify a range of consecutive values in a single
case
...
low
high
This has the same effect as the proper number of individual
from
to
, inclusive.
low
high
This feature is especially useful for ranges of ASCII character codes:
case 'A' ... 'Z':
Be careful: Write spaces around the
integer values. For example, write this:
case 1 ... 5:
rather than this:
case 1...5:

6.24. Cast to a Union Type

A cast to union type is similar to other casts, except that the type specified is a union type. You
can specify the type either with
constructor though, not a cast, and hence does not yield an lvalue like normal casts. (refer to Section
6.21 Compound Literals.)
The types that may be cast to the union type are those of the members of the union. Thus, given the
following union and variables:
union foo { int i; double d; };
int x;
double y;
both
and
can be cast to type
x
y
Using the cast as the right-hand side of an assignment to a variable of union type is equivalent to
storing in a member of the union:
union foo u;
/* ... */
u = (union foo) x
u = (union foo) y
You can also use the union cast as a function argument:
.
fieldname
struct point
:
, for otherwise it may be parsed wrong when you use it with
...
union
tag
union foo
==
u.i = x
==
u.d = y
Chapter 6. Extensions to the C Language Family
and
designators before an
[
]
index
declaration above:
label, like this:
case
case
or with a typedef name. A cast to union is actually a
.
to specify a nested
=
labels, one for each integer value

Advertisement

Table of Contents
loading

This manual is also suitable for:

Enterprise linux 3

Table of Contents