extend.texi (258748) | extend.texi (260014) |
---|---|
1@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1996, 1998, 1999, 2000, 2@c 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. 3 4@c This is part of the GCC manual. 5@c For copying conditions, see the file gcc.texi. 6 7@node C Extensions 8@chapter Extensions to the C Language Family --- 44 unchanged lines hidden (view full) --- 53 or that they can never return. 54* Attribute Syntax:: Formal syntax for attributes. 55* Function Prototypes:: Prototype declarations and old-style definitions. 56* C++ Comments:: C++ comments are recognized. 57* Dollar Signs:: Dollar sign is allowed in identifiers. 58* Character Escapes:: @samp{\e} stands for the character @key{ESC}. 59* Variable Attributes:: Specifying attributes of variables. 60* Type Attributes:: Specifying attributes of types. | 1@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1996, 1998, 1999, 2000, 2@c 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. 3 4@c This is part of the GCC manual. 5@c For copying conditions, see the file gcc.texi. 6 7@node C Extensions 8@chapter Extensions to the C Language Family --- 44 unchanged lines hidden (view full) --- 53 or that they can never return. 54* Attribute Syntax:: Formal syntax for attributes. 55* Function Prototypes:: Prototype declarations and old-style definitions. 56* C++ Comments:: C++ comments are recognized. 57* Dollar Signs:: Dollar sign is allowed in identifiers. 58* Character Escapes:: @samp{\e} stands for the character @key{ESC}. 59* Variable Attributes:: Specifying attributes of variables. 60* Type Attributes:: Specifying attributes of types. |
61@c APPLE LOCAL begin for-fsf-4_4 3274130 5295549 62* Label Attributes:: Specifying attributes of labels and statements. 63@c APPLE LOCAL end for-fsf-4_4 3274130 5295549 |
|
61* Alignment:: Inquiring about the alignment of a type or variable. 62* Inline:: Defining inline functions (as fast as macros). 63* Extended Asm:: Assembler instructions with C expressions as operands. 64 (With them you can define ``built-in'' functions.) 65* Constraints:: Constraints for asm operands 66* Asm Labels:: Specifying the assembler name to use for a C symbol. 67* Explicit Reg Vars:: Defining variables residing in specified registers. 68* Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files. --- 1513 unchanged lines hidden (view full) --- 1582@code{flatten}, @code{pure}, @code{const}, @code{nothrow}, @code{sentinel}, 1583@code{format}, @code{format_arg}, @code{no_instrument_function}, 1584@code{section}, @code{constructor}, @code{destructor}, @code{used}, 1585@code{unused}, @code{deprecated}, @code{weak}, @code{malloc}, 1586@code{alias}, @code{warn_unused_result}, @code{nonnull}, 1587@code{gnu_inline} and @code{externally_visible}. Several other 1588attributes are defined for functions on particular target systems. Other 1589attributes, including @code{section} are supported for variables declarations | 64* Alignment:: Inquiring about the alignment of a type or variable. 65* Inline:: Defining inline functions (as fast as macros). 66* Extended Asm:: Assembler instructions with C expressions as operands. 67 (With them you can define ``built-in'' functions.) 68* Constraints:: Constraints for asm operands 69* Asm Labels:: Specifying the assembler name to use for a C symbol. 70* Explicit Reg Vars:: Defining variables residing in specified registers. 71* Alternate Keywords:: @code{__const__}, @code{__asm__}, etc., for header files. --- 1513 unchanged lines hidden (view full) --- 1585@code{flatten}, @code{pure}, @code{const}, @code{nothrow}, @code{sentinel}, 1586@code{format}, @code{format_arg}, @code{no_instrument_function}, 1587@code{section}, @code{constructor}, @code{destructor}, @code{used}, 1588@code{unused}, @code{deprecated}, @code{weak}, @code{malloc}, 1589@code{alias}, @code{warn_unused_result}, @code{nonnull}, 1590@code{gnu_inline} and @code{externally_visible}. Several other 1591attributes are defined for functions on particular target systems. Other 1592attributes, including @code{section} are supported for variables declarations |
1590(@pxref{Variable Attributes}) and for types (@pxref{Type Attributes}). | 1593@c APPLE LOCAL begin for-fsf-4_4 3274130 5295549 1594(@pxref{Variable Attributes}), for types (@pxref{Type Attributes}), 1595and labels (@pxref{Label Attributes}). |
1591 | 1596 |
1597@c APPLE LOCAL end for-fsf-4_4 3274130 5295549 |
|
1592You may also specify attributes with @samp{__} preceding and following 1593each keyword. This allows you to use them in header files without 1594being concerned about a possible macro of the same name. For example, 1595you may use @code{__noreturn__} instead of @code{noreturn}. 1596 1597@xref{Attribute Syntax}, for details of the exact syntax for using 1598attributes. 1599 --- 1035 unchanged lines hidden (view full) --- 2635code generation, so problems may arise when attributed types are used in 2636conjunction with templates or overloading. Similarly, @code{typeid} 2637does not distinguish between types with different attributes. Support 2638for attributes in C++ may be restricted in future to attributes on 2639declarations only, but not on nested declarators. 2640 2641@xref{Function Attributes}, for details of the semantics of attributes 2642applying to functions. @xref{Variable Attributes}, for details of the | 1598You may also specify attributes with @samp{__} preceding and following 1599each keyword. This allows you to use them in header files without 1600being concerned about a possible macro of the same name. For example, 1601you may use @code{__noreturn__} instead of @code{noreturn}. 1602 1603@xref{Attribute Syntax}, for details of the exact syntax for using 1604attributes. 1605 --- 1035 unchanged lines hidden (view full) --- 2641code generation, so problems may arise when attributed types are used in 2642conjunction with templates or overloading. Similarly, @code{typeid} 2643does not distinguish between types with different attributes. Support 2644for attributes in C++ may be restricted in future to attributes on 2645declarations only, but not on nested declarators. 2646 2647@xref{Function Attributes}, for details of the semantics of attributes 2648applying to functions. @xref{Variable Attributes}, for details of the |
2643semantics of attributes applying to variables. @xref{Type Attributes}, 2644for details of the semantics of attributes applying to structure, union 2645and enumerated types. | 2649@c APPLE LOCAL begin for-fsf-4_4 3274130 5295549 2650semantics of attributes applying to variables. @xref{Type 2651Attributes}, for details of the semantics of attributes applying to 2652structure, union and enumerated types. @xref{Label Attributes}, for 2653details of the semantics of attributes applying to labels and 2654statements. |
2646 | 2655 |
2656@c APPLE LOCAL end for-fsf-4_4 3274130 5295549 |
|
2647An @dfn{attribute specifier} is of the form 2648@code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list} 2649is a possibly empty comma-separated sequence of @dfn{attributes}, where 2650each attribute is one of the following: 2651 2652@itemize @bullet 2653@item 2654Empty. Empty attributes are ignored. --- 20 unchanged lines hidden (view full) --- 2675integer constant expression, and @code{alias} attributes use this form 2676with the list being a single string constant. 2677@end itemize 2678@end itemize 2679 2680An @dfn{attribute specifier list} is a sequence of one or more attribute 2681specifiers, not separated by any other tokens. 2682 | 2657An @dfn{attribute specifier} is of the form 2658@code{__attribute__ ((@var{attribute-list}))}. An @dfn{attribute list} 2659is a possibly empty comma-separated sequence of @dfn{attributes}, where 2660each attribute is one of the following: 2661 2662@itemize @bullet 2663@item 2664Empty. Empty attributes are ignored. --- 20 unchanged lines hidden (view full) --- 2685integer constant expression, and @code{alias} attributes use this form 2686with the list being a single string constant. 2687@end itemize 2688@end itemize 2689 2690An @dfn{attribute specifier list} is a sequence of one or more attribute 2691specifiers, not separated by any other tokens. 2692 |
2683In GNU C, an attribute specifier list may appear after the colon following a 2684label, other than a @code{case} or @code{default} label. The only 2685attribute it makes sense to use after a label is @code{unused}. This 2686feature is intended for code generated by programs which contains labels 2687that may be unused but which is compiled with @option{-Wall}. It would 2688not normally be appropriate to use in it human-written code, though it 2689could be useful in cases where the code that jumps to the label is 2690contained within an @code{#ifdef} conditional. GNU C++ does not permit 2691such placement of attribute lists, as it is permissible for a 2692declaration, which could begin with an attribute list, to be labelled in 2693C++. Declarations cannot be labelled in C90 or C99, so the ambiguity 2694does not arise there. | 2693@c APPLE LOCAL begin for-fsf-4_4 3274130 5295549 2694In GNU C, an attribute specifier list may appear after the colon 2695following a label, other than a @code{case} or @code{default} label. 2696GNU C++ does not permit such placement of attribute lists, as it is 2697permissible for a declaration, which could begin with an attribute 2698list, to be labelled in C++. Declarations cannot be labelled in C90 2699or C99, so the ambiguity does not arise there. |
2695 | 2700 |
2701In GNU C an attribute specifier list may also appear after the keyword 2702@code{while} in a while loop, after @code{do} and after @code{for}. 2703 2704@c APPLE LOCAL end for-fsf-4_4 3274130 5295549 |
|
2696An attribute specifier list may appear as part of a @code{struct}, 2697@code{union} or @code{enum} specifier. It may go either immediately 2698after the @code{struct}, @code{union} or @code{enum} keyword, or after 2699the closing brace. The former syntax is preferred. 2700Where attribute specifiers follow the closing brace, they are considered 2701to relate to the structure, union or enumerated type defined, not to any 2702enclosing declaration the type specifier appears in, and the type 2703defined is not complete until after the attribute specifiers. --- 287 unchanged lines hidden (view full) --- 2991@cindex variable attributes 2992 2993The keyword @code{__attribute__} allows you to specify special 2994attributes of variables or structure fields. This keyword is followed 2995by an attribute specification inside double parentheses. Some 2996attributes are currently defined generically for variables. 2997Other attributes are defined for variables on particular target 2998systems. Other attributes are available for functions | 2705An attribute specifier list may appear as part of a @code{struct}, 2706@code{union} or @code{enum} specifier. It may go either immediately 2707after the @code{struct}, @code{union} or @code{enum} keyword, or after 2708the closing brace. The former syntax is preferred. 2709Where attribute specifiers follow the closing brace, they are considered 2710to relate to the structure, union or enumerated type defined, not to any 2711enclosing declaration the type specifier appears in, and the type 2712defined is not complete until after the attribute specifiers. --- 287 unchanged lines hidden (view full) --- 3000@cindex variable attributes 3001 3002The keyword @code{__attribute__} allows you to specify special 3003attributes of variables or structure fields. This keyword is followed 3004by an attribute specification inside double parentheses. Some 3005attributes are currently defined generically for variables. 3006Other attributes are defined for variables on particular target 3007systems. Other attributes are available for functions |
2999(@pxref{Function Attributes}) and for types (@pxref{Type Attributes}). 3000Other front ends might define more attributes 3001(@pxref{C++ Extensions,,Extensions to the C++ Language}). | 3008@c APPLE LOCAL begin for-fsf-4_4 3274130 5295549 3009(@pxref{Function Attributes}), types (@pxref{Type Attributes}) and 3010labels (@pxref{Label Attributes}). Other front ends might define 3011more attributes (@pxref{C++ Extensions,,Extensions to the C++ Language}). |
3002 | 3012 |
3013@c APPLE LOCAL end for-fsf-4_4 3274130 5295549 |
|
3003You may also specify attributes with @samp{__} preceding and following 3004each keyword. This allows you to use them in header files without 3005being concerned about a possible macro of the same name. For example, 3006you may use @code{__aligned__} instead of @code{aligned}. 3007 3008@xref{Attribute Syntax}, for details of the exact syntax for using 3009attributes. 3010 --- 480 unchanged lines hidden (view full) --- 3491 3492The keyword @code{__attribute__} allows you to specify special 3493attributes of @code{struct} and @code{union} types when you define 3494such types. This keyword is followed by an attribute specification 3495inside double parentheses. Seven attributes are currently defined for 3496types: @code{aligned}, @code{packed}, @code{transparent_union}, 3497@code{unused}, @code{deprecated}, @code{visibility}, and 3498@code{may_alias}. Other attributes are defined for functions | 3014You may also specify attributes with @samp{__} preceding and following 3015each keyword. This allows you to use them in header files without 3016being concerned about a possible macro of the same name. For example, 3017you may use @code{__aligned__} instead of @code{aligned}. 3018 3019@xref{Attribute Syntax}, for details of the exact syntax for using 3020attributes. 3021 --- 480 unchanged lines hidden (view full) --- 3502 3503The keyword @code{__attribute__} allows you to specify special 3504attributes of @code{struct} and @code{union} types when you define 3505such types. This keyword is followed by an attribute specification 3506inside double parentheses. Seven attributes are currently defined for 3507types: @code{aligned}, @code{packed}, @code{transparent_union}, 3508@code{unused}, @code{deprecated}, @code{visibility}, and 3509@code{may_alias}. Other attributes are defined for functions |
3499(@pxref{Function Attributes}) and for variables (@pxref{Variable 3500Attributes}). | 3510@c APPLE LOCAL begin for-fsf-4_4 3274130 5295549 3511(@pxref{Function Attributes}), variables (@pxref{Variable 3512Attributes}), and labels (@pxref{Label Attributes}). |
3501 | 3513 |
3514@c APPLE LOCAL end for-fsf-4_4 3274130 5295549 |
|
3502You may also specify any one of these attributes with @samp{__} 3503preceding and following its keyword. This allows you to use these 3504attributes in header files without being concerned about a possible 3505macro of the same name. For example, you may use @code{__aligned__} 3506instead of @code{aligned}. 3507 3508You may specify type attributes either in a @code{typedef} declaration 3509or in an enum, struct or union type declaration or definition. --- 331 unchanged lines hidden (view full) --- 3841__attribute__((altivec(vector__))) 3842__attribute__((altivec(pixel__))) unsigned short 3843__attribute__((altivec(bool__))) unsigned 3844@end smallexample 3845 3846These attributes mainly are intended to support the @code{__vector}, 3847@code{__pixel}, and @code{__bool} AltiVec keywords. 3848 | 3515You may also specify any one of these attributes with @samp{__} 3516preceding and following its keyword. This allows you to use these 3517attributes in header files without being concerned about a possible 3518macro of the same name. For example, you may use @code{__aligned__} 3519instead of @code{aligned}. 3520 3521You may specify type attributes either in a @code{typedef} declaration 3522or in an enum, struct or union type declaration or definition. --- 331 unchanged lines hidden (view full) --- 3854__attribute__((altivec(vector__))) 3855__attribute__((altivec(pixel__))) unsigned short 3856__attribute__((altivec(bool__))) unsigned 3857@end smallexample 3858 3859These attributes mainly are intended to support the @code{__vector}, 3860@code{__pixel}, and @code{__bool} AltiVec keywords. 3861 |
3862@c APPLE LOCAL begin for-fsf-4_4 3274130 5295549 3863@node Label Attributes 3864@section Specifying Attributes of Labels and Statements 3865@cindex attribute of labels 3866@cindex label attributes 3867@cindex attribute of statements 3868@cindex statement attributes 3869 3870The keyword @code{__attribute__} allows you to specify special 3871attributes of labels and statements. 3872 3873Some attributes are currently defined generically for variables. 3874Other attributes are defined for variables on particular target 3875systems. Other attributes are available for functions 3876(@pxref{Function Attributes}), types (@pxref{Type Attributes}) and 3877variables (@pxref{Variable Attributes}). 3878 3879You may also specify attributes with @samp{__} preceding and following 3880each keyword. This allows you to use them in header files without 3881being concerned about a possible macro of the same name. For example, 3882you may use @code{__aligned__} instead of @code{aligned}. 3883 3884@xref{Attribute Syntax}, for details of the exact syntax for using 3885attributes. 3886 3887@table @code 3888@cindex @code{aligned} attribute 3889@item aligned (@var{alignment}) 3890This attribute specifies a minimum alignment for the label, 3891measured in bytes. For example, the declaration: 3892 3893@smallexample 3894 some_label: __attribute__((aligned(16))) 3895@end smallexample 3896 3897@noindent 3898requests the compiler to align the label, inserting @code{nop}s as necessary, 3899to a 16-byte boundary. 3900 3901The alignment is only a request. The compiler will usually be able to 3902honour it but sometimes the label will be eliminated by the compiler, 3903in which case its alignment will be eliminated too. 3904 3905When applied to loops, the @code{aligned} attribute causes the loop to 3906be aligned. 3907 3908@item unused 3909When attached to a label this attribute means that the label might not 3910be used. GCC will not produce a warning for the label, even if the 3911label doesn't seem to be referenced. This feature is intended for 3912code generated by programs which contains labels that may be unused 3913but which is compiled with @option{-Wall}. It would not normally be 3914appropriate to use in it human-written code, though it could be useful 3915in cases where the code that jumps to the label is contained within an 3916@code{#ifdef} conditional. 3917 3918This attribute can only be applied to labels, not statements, because 3919there is no warning if a statement is removed. 3920@end table 3921 3922@c APPLE LOCAL end for-fsf-4_4 3274130 5295549 |
|
3849@node Inline 3850@section An Inline Function is As Fast As a Macro 3851@cindex inline functions 3852@cindex integrating function code 3853@cindex open coding 3854@cindex macros, inline alternative 3855 3856By declaring a function inline, you can direct GCC to make --- 7339 unchanged lines hidden --- | 3923@node Inline 3924@section An Inline Function is As Fast As a Macro 3925@cindex inline functions 3926@cindex integrating function code 3927@cindex open coding 3928@cindex macros, inline alternative 3929 3930By declaring a function inline, you can direct GCC to make --- 7339 unchanged lines hidden --- |