You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

243 lines
19KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>C Extensions (Using the GNU Compiler Collection (GCC))</title>
  21. <meta name="description" content="C Extensions (Using the GNU Compiler Collection (GCC))">
  22. <meta name="keywords" content="C Extensions (Using the GNU Compiler Collection (GCC))">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="index.html#Top" rel="up" title="Top">
  30. <link href="Statement-Exprs.html#Statement-Exprs" rel="next" title="Statement Exprs">
  31. <link href="Exception-handling.html#Exception-handling" rel="prev" title="Exception handling">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style: oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="C-Extensions"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="C_002b_002b-Extensions.html#C_002b_002b-Extensions" accesskey="n" rel="next">C++ Extensions</a>, Previous: <a href="C_002b_002b-Implementation.html#C_002b_002b-Implementation" accesskey="p" rel="prev">C++ Implementation</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  65. </div>
  66. <hr>
  67. <a name="Extensions-to-the-C-Language-Family"></a>
  68. <h2 class="chapter">6 Extensions to the C Language Family</h2>
  69. <a name="index-extensions_002c-C-language"></a>
  70. <a name="index-C-language-extensions"></a>
  71. <a name="index-pedantic-2"></a>
  72. <p>GNU C provides several language features not found in ISO standard C.
  73. (The <samp>-pedantic</samp> option directs GCC to print a warning message if
  74. any of these features is used.) To test for the availability of these
  75. features in conditional compilation, check for a predefined macro
  76. <code>__GNUC__</code>, which is always defined under GCC.
  77. </p>
  78. <p>These extensions are available in C and Objective-C. Most of them are
  79. also available in C++. See <a href="C_002b_002b-Extensions.html#C_002b_002b-Extensions">Extensions to the
  80. C++ Language</a>, for extensions that apply <em>only</em> to C++.
  81. </p>
  82. <p>Some features that are in ISO C99 but not C90 or C++ are also, as
  83. extensions, accepted by GCC in C90 mode and in C++.
  84. </p>
  85. <table class="menu" border="0" cellspacing="0">
  86. <tr><td align="left" valign="top">&bull; <a href="Statement-Exprs.html#Statement-Exprs" accesskey="1">Statement Exprs</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Putting statements and declarations inside expressions.
  87. </td></tr>
  88. <tr><td align="left" valign="top">&bull; <a href="Local-Labels.html#Local-Labels" accesskey="2">Local Labels</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Labels local to a block.
  89. </td></tr>
  90. <tr><td align="left" valign="top">&bull; <a href="Labels-as-Values.html#Labels-as-Values" accesskey="3">Labels as Values</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Getting pointers to labels, and computed gotos.
  91. </td></tr>
  92. <tr><td align="left" valign="top">&bull; <a href="Nested-Functions.html#Nested-Functions" accesskey="4">Nested Functions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Nested function in GNU C.
  93. </td></tr>
  94. <tr><td align="left" valign="top">&bull; <a href="Nonlocal-Gotos.html#Nonlocal-Gotos" accesskey="5">Nonlocal Gotos</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Nonlocal gotos.
  95. </td></tr>
  96. <tr><td align="left" valign="top">&bull; <a href="Constructing-Calls.html#Constructing-Calls" accesskey="6">Constructing Calls</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Dispatching a call to another function.
  97. </td></tr>
  98. <tr><td align="left" valign="top">&bull; <a href="Typeof.html#Typeof" accesskey="7">Typeof</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top"><code>typeof</code>: referring to the type of an expression.
  99. </td></tr>
  100. <tr><td align="left" valign="top">&bull; <a href="Conditionals.html#Conditionals" accesskey="8">Conditionals</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Omitting the middle operand of a &lsquo;<samp>?:</samp>&rsquo; expression.
  101. </td></tr>
  102. <tr><td align="left" valign="top">&bull; <a href="_005f_005fint128.html#g_t_005f_005fint128" accesskey="9">__int128</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">128-bit integers&mdash;<code>__int128</code>.
  103. </td></tr>
  104. <tr><td align="left" valign="top">&bull; <a href="Long-Long.html#Long-Long">Long Long</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Double-word integers&mdash;<code>long long int</code>.
  105. </td></tr>
  106. <tr><td align="left" valign="top">&bull; <a href="Complex.html#Complex">Complex</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Data types for complex numbers.
  107. </td></tr>
  108. <tr><td align="left" valign="top">&bull; <a href="Floating-Types.html#Floating-Types">Floating Types</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Additional Floating Types.
  109. </td></tr>
  110. <tr><td align="left" valign="top">&bull; <a href="Half_002dPrecision.html#Half_002dPrecision">Half-Precision</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Half-Precision Floating Point.
  111. </td></tr>
  112. <tr><td align="left" valign="top">&bull; <a href="Decimal-Float.html#Decimal-Float">Decimal Float</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Decimal Floating Types.
  113. </td></tr>
  114. <tr><td align="left" valign="top">&bull; <a href="Hex-Floats.html#Hex-Floats">Hex Floats</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Hexadecimal floating-point constants.
  115. </td></tr>
  116. <tr><td align="left" valign="top">&bull; <a href="Fixed_002dPoint.html#Fixed_002dPoint">Fixed-Point</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Fixed-Point Types.
  117. </td></tr>
  118. <tr><td align="left" valign="top">&bull; <a href="Named-Address-Spaces.html#Named-Address-Spaces">Named Address Spaces</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Named address spaces.
  119. </td></tr>
  120. <tr><td align="left" valign="top">&bull; <a href="Zero-Length.html#Zero-Length">Zero Length</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Zero-length arrays.
  121. </td></tr>
  122. <tr><td align="left" valign="top">&bull; <a href="Empty-Structures.html#Empty-Structures">Empty Structures</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Structures with no members.
  123. </td></tr>
  124. <tr><td align="left" valign="top">&bull; <a href="Variable-Length.html#Variable-Length">Variable Length</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Arrays whose length is computed at run time.
  125. </td></tr>
  126. <tr><td align="left" valign="top">&bull; <a href="Variadic-Macros.html#Variadic-Macros">Variadic Macros</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Macros with a variable number of arguments.
  127. </td></tr>
  128. <tr><td align="left" valign="top">&bull; <a href="Escaped-Newlines.html#Escaped-Newlines">Escaped Newlines</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Slightly looser rules for escaped newlines.
  129. </td></tr>
  130. <tr><td align="left" valign="top">&bull; <a href="Subscripting.html#Subscripting">Subscripting</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Any array can be subscripted, even if not an lvalue.
  131. </td></tr>
  132. <tr><td align="left" valign="top">&bull; <a href="Pointer-Arith.html#Pointer-Arith">Pointer Arith</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Arithmetic on <code>void</code>-pointers and function pointers.
  133. </td></tr>
  134. <tr><td align="left" valign="top">&bull; <a href="Variadic-Pointer-Args.html#Variadic-Pointer-Args">Variadic Pointer Args</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Pointer arguments to variadic functions.
  135. </td></tr>
  136. <tr><td align="left" valign="top">&bull; <a href="Pointers-to-Arrays.html#Pointers-to-Arrays">Pointers to Arrays</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Pointers to arrays with qualifiers work as expected.
  137. </td></tr>
  138. <tr><td align="left" valign="top">&bull; <a href="Initializers.html#Initializers">Initializers</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Non-constant initializers.
  139. </td></tr>
  140. <tr><td align="left" valign="top">&bull; <a href="Compound-Literals.html#Compound-Literals">Compound Literals</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Compound literals give structures, unions
  141. or arrays as values.
  142. </td></tr>
  143. <tr><td align="left" valign="top">&bull; <a href="Designated-Inits.html#Designated-Inits">Designated Inits</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Labeling elements of initializers.
  144. </td></tr>
  145. <tr><td align="left" valign="top">&bull; <a href="Case-Ranges.html#Case-Ranges">Case Ranges</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">&lsquo;case 1 ... 9&rsquo; and such.
  146. </td></tr>
  147. <tr><td align="left" valign="top">&bull; <a href="Cast-to-Union.html#Cast-to-Union">Cast to Union</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Casting to union type from any member of the union.
  148. </td></tr>
  149. <tr><td align="left" valign="top">&bull; <a href="Mixed-Declarations.html#Mixed-Declarations">Mixed Declarations</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Mixing declarations and code.
  150. </td></tr>
  151. <tr><td align="left" valign="top">&bull; <a href="Function-Attributes.html#Function-Attributes">Function Attributes</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Declaring that functions have no side effects,
  152. or that they can never return.
  153. </td></tr>
  154. <tr><td align="left" valign="top">&bull; <a href="Variable-Attributes.html#Variable-Attributes">Variable Attributes</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Specifying attributes of variables.
  155. </td></tr>
  156. <tr><td align="left" valign="top">&bull; <a href="Type-Attributes.html#Type-Attributes">Type Attributes</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Specifying attributes of types.
  157. </td></tr>
  158. <tr><td align="left" valign="top">&bull; <a href="Label-Attributes.html#Label-Attributes">Label Attributes</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Specifying attributes on labels.
  159. </td></tr>
  160. <tr><td align="left" valign="top">&bull; <a href="Enumerator-Attributes.html#Enumerator-Attributes">Enumerator Attributes</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Specifying attributes on enumerators.
  161. </td></tr>
  162. <tr><td align="left" valign="top">&bull; <a href="Statement-Attributes.html#Statement-Attributes">Statement Attributes</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Specifying attributes on statements.
  163. </td></tr>
  164. <tr><td align="left" valign="top">&bull; <a href="Attribute-Syntax.html#Attribute-Syntax">Attribute Syntax</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Formal syntax for attributes.
  165. </td></tr>
  166. <tr><td align="left" valign="top">&bull; <a href="Function-Prototypes.html#Function-Prototypes">Function Prototypes</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Prototype declarations and old-style definitions.
  167. </td></tr>
  168. <tr><td align="left" valign="top">&bull; <a href="C_002b_002b-Comments.html#C_002b_002b-Comments">C++ Comments</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">C++ comments are recognized.
  169. </td></tr>
  170. <tr><td align="left" valign="top">&bull; <a href="Dollar-Signs.html#Dollar-Signs">Dollar Signs</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Dollar sign is allowed in identifiers.
  171. </td></tr>
  172. <tr><td align="left" valign="top">&bull; <a href="Character-Escapes.html#Character-Escapes">Character Escapes</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">&lsquo;<samp>\e</samp>&rsquo; stands for the character <tt class="key">ESC</tt>.
  173. </td></tr>
  174. <tr><td align="left" valign="top">&bull; <a href="Alignment.html#Alignment">Alignment</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Determining the alignment of a function, type or variable.
  175. </td></tr>
  176. <tr><td align="left" valign="top">&bull; <a href="Inline.html#Inline">Inline</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Defining inline functions (as fast as macros).
  177. </td></tr>
  178. <tr><td align="left" valign="top">&bull; <a href="Volatiles.html#Volatiles">Volatiles</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">What constitutes an access to a volatile object.
  179. </td></tr>
  180. <tr><td align="left" valign="top">&bull; <a href="Using-Assembly-Language-with-C.html#Using-Assembly-Language-with-C">Using Assembly Language with C</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Instructions and extensions for interfacing C with assembler.
  181. </td></tr>
  182. <tr><td align="left" valign="top">&bull; <a href="Alternate-Keywords.html#Alternate-Keywords">Alternate Keywords</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top"><code>__const__</code>, <code>__asm__</code>, etc., for header files.
  183. </td></tr>
  184. <tr><td align="left" valign="top">&bull; <a href="Incomplete-Enums.html#Incomplete-Enums">Incomplete Enums</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top"><code>enum foo;</code>, with details to follow.
  185. </td></tr>
  186. <tr><td align="left" valign="top">&bull; <a href="Function-Names.html#Function-Names">Function Names</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Printable strings which are the name of the current
  187. function.
  188. </td></tr>
  189. <tr><td align="left" valign="top">&bull; <a href="Return-Address.html#Return-Address">Return Address</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Getting the return or frame address of a function.
  190. </td></tr>
  191. <tr><td align="left" valign="top">&bull; <a href="Vector-Extensions.html#Vector-Extensions">Vector Extensions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Using vector instructions through built-in functions.
  192. </td></tr>
  193. <tr><td align="left" valign="top">&bull; <a href="Offsetof.html#Offsetof">Offsetof</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Special syntax for implementing <code>offsetof</code>.
  194. </td></tr>
  195. <tr><td align="left" valign="top">&bull; <a href="_005f_005fsync-Builtins.html#g_t_005f_005fsync-Builtins">__sync Builtins</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Legacy built-in functions for atomic memory access.
  196. </td></tr>
  197. <tr><td align="left" valign="top">&bull; <a href="_005f_005fatomic-Builtins.html#g_t_005f_005fatomic-Builtins">__atomic Builtins</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Atomic built-in functions with memory model.
  198. </td></tr>
  199. <tr><td align="left" valign="top">&bull; <a href="Integer-Overflow-Builtins.html#Integer-Overflow-Builtins">Integer Overflow Builtins</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Built-in functions to perform arithmetics and
  200. arithmetic overflow checking.
  201. </td></tr>
  202. <tr><td align="left" valign="top">&bull; <a href="x86-specific-memory-model-extensions-for-transactional-memory.html#x86-specific-memory-model-extensions-for-transactional-memory">x86 specific memory model extensions for transactional memory</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">x86 memory models.
  203. </td></tr>
  204. <tr><td align="left" valign="top">&bull; <a href="Object-Size-Checking.html#Object-Size-Checking">Object Size Checking</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Built-in functions for limited buffer overflow
  205. checking.
  206. </td></tr>
  207. <tr><td align="left" valign="top">&bull; <a href="Other-Builtins.html#Other-Builtins">Other Builtins</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Other built-in functions.
  208. </td></tr>
  209. <tr><td align="left" valign="top">&bull; <a href="Target-Builtins.html#Target-Builtins">Target Builtins</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Built-in functions specific to particular targets.
  210. </td></tr>
  211. <tr><td align="left" valign="top">&bull; <a href="Target-Format-Checks.html#Target-Format-Checks">Target Format Checks</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Format checks specific to particular targets.
  212. </td></tr>
  213. <tr><td align="left" valign="top">&bull; <a href="Pragmas.html#Pragmas">Pragmas</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Pragmas accepted by GCC.
  214. </td></tr>
  215. <tr><td align="left" valign="top">&bull; <a href="Unnamed-Fields.html#Unnamed-Fields">Unnamed Fields</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Unnamed struct/union fields within structs/unions.
  216. </td></tr>
  217. <tr><td align="left" valign="top">&bull; <a href="Thread_002dLocal.html#Thread_002dLocal">Thread-Local</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Per-thread variables.
  218. </td></tr>
  219. <tr><td align="left" valign="top">&bull; <a href="Binary-constants.html#Binary-constants">Binary constants</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Binary constants using the &lsquo;<samp>0b</samp>&rsquo; prefix.
  220. </td></tr>
  221. </table>
  222. <hr>
  223. <div class="header">
  224. <p>
  225. Next: <a href="C_002b_002b-Extensions.html#C_002b_002b-Extensions" accesskey="n" rel="next">C++ Extensions</a>, Previous: <a href="C_002b_002b-Implementation.html#C_002b_002b-Implementation" accesskey="p" rel="prev">C++ Implementation</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  226. </div>
  227. </body>
  228. </html>