C++ Style Comments; Dollar Signs In Identifier Names; The Character [Esc] In Constants; Inquiring On Alignment Of Types Or Variables - Red Hat ENTERPRISE LINUX 4 Manual

Hide thumbs Also See for ENTERPRISE LINUX 4:
Table of Contents

Advertisement

Chapter 6. Extensions to the C Language Family
163

6.28. C++ Style Comments

In GNU C, you may use C++ style comments, which start with
and continue until the end of
//
the line. Many other C implementations allow such comments, and they are included in the 1999 C
standard. However, C++ style comments are not recognized if you specify an
option specifying
-std
a version of ISO C before C99, or
(equivalent to
).
-ansi
-std=c89
6.29. Dollar Signs in Identifier Names
In GNU C, you may normally use dollar signs in identifier names. This is because many traditional
C implementations allow such identifiers. However, dollar signs in identifiers are not supported on a
few target machines, typically because the target assembler does not allow them.

6.30. The Character [ESC] in Constants

You can use the sequence
in a string or character constant to stand for the ASCII character [ESC].
\e

6.31. Inquiring on Alignment of Types or Variables

The keyword
allows you to inquire about how an object is aligned, or the minimum
__alignof__
alignment usually required by a type. Its syntax is just like
.
sizeof
For example, if the target machine requires a
value to be aligned on an 8-byte boundary, then
double
is 8. This is true on many RISC machines. On more traditional machine
__alignof__ (double)
designs,
is 4 or even 2.
__alignof__ (double)
Some machines never actually require alignment; they allow reference to any data type even at an odd
address. For these machines,
reports the recommended alignment of a type.
__alignof__
If the operand of
is an lvalue rather than a type, its value is the required alignment
__alignof__
for its type, taking into account any minimum alignment specified with GCC's
__attribute__
extension (Section 6.32 Specifying Attributes of Variables). For example, after this declaration:
struct foo { int x; char y; } foo1;
the value of
is 1, even though its actual alignment is probably 2 or 4, the
__alignof__ (foo1.y)
same as
.
__alignof__ (int)
It is an error to ask for the alignment of an incomplete type.

6.32. Specifying Attributes of Variables

The keyword
allows you to specify special attributes of variables or structure fields.
__attribute__
This keyword is followed by an attribute specification inside double parentheses. Some attributes
are currently defined generically for variables. Other attributes are defined for variables on particular
target systems. Other attributes are available for functions (Section 6.25 Declaring Attributes of Func-
tions) and for types (Section 6.33 Specifying Attributes of Types). Other front ends might define more
attributes (Chapter 7 Extensions to the C++ Language).
You may also specify attributes with
preceding and following each keyword. This allows you to use
__
them in header files without being concerned about a possible macro of the same name. For example,
you may use
instead of
.
__aligned__
aligned
Section 6.26 Attribute Syntax, for details of the exact syntax for using attributes.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ENTERPRISE LINUX 4 and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents