From: Alejandro Colomar Date: Tue, 14 Oct 2025 14:41:29 +0000 (+0200) Subject: doc: Move _Countof under 'Other Extensions to C Syntax' X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e5b5a1322dec8d713d649378529ee28b816b5b1b;p=thirdparty%2Fgcc.git doc: Move _Countof under 'Other Extensions to C Syntax' gcc/ChangeLog: * doc/extend.texi: Move _Countof under 'Syntax Extensions'. Signed-off-by: Alejandro Colomar --- diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 74278258206..a5b97f37d9d 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -31,7 +31,6 @@ extensions, accepted by GCC in C90 mode and in C++. * Thread-Local:: Per-thread variables. * OpenMP:: Multiprocessing extensions. * OpenACC:: Extensions for offloading code to accelerator devices. -* _Countof:: The number of elements of arrays. * Inline:: Defining inline functions (as fast as macros). * Volatiles:: What constitutes an access to a volatile object. * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler. @@ -10890,36 +10889,6 @@ library. @xref{OpenMP and OpenACC Options}, for additional options useful with @option{-fopenacc}. -@node _Countof -@section Determining the Number of Elements of Arrays -@cindex _Countof -@cindex number of elements - -The keyword @code{_Countof} determines -the number of elements of an array operand. -Its syntax is similar to @code{sizeof}. -The operand must be -a parenthesized complete array type name -or an expression of such a type. -For example: - -@smallexample -int a[n]; -_Countof (a); // returns n -_Countof (int [7][3]); // returns 7 -@end smallexample - -The result of this operator is an integer constant expression, -unless the array has a variable number of elements. -The operand is only evaluated -if the array has a variable number of elements. -For example: - -@smallexample -_Countof (int [7][n++]); // integer constant expression -_Countof (int [n++][7]); // run-time value; n++ is evaluated -@end smallexample - @node Inline @section An Inline Function is As Fast As a Macro @cindex inline functions @@ -13341,6 +13310,7 @@ C and/or C++ standards, while others remain specific to GNU C. * Labels as Values:: Getting pointers to labels, and computed gotos. * Nested Functions:: Nested functions in GNU C. * Typeof:: @code{typeof}: referring to the type of an expression. +* _Countof:: Determining the number of elements of arrays * Offsetof:: Special syntax for @code{offsetof}. * Alignment:: Determining the alignment of a function, type or variable. * Enum Extensions:: Forward declarations and specifying the underlying type. @@ -13977,6 +13947,36 @@ evaluated only once when using @code{__auto_type}, but twice if @code{typeof} is used. @end itemize +@node _Countof +@subsection Determining the Number of Elements of Arrays +@findex _Countof +@findex number of elements + +The keyword @code{_Countof} determines +the number of elements of an array operand. +Its syntax is similar to @code{sizeof}. +The operand must be +a parenthesized complete array type name +or an expression of such a type. +For example: + +@smallexample +int a[n]; +_Countof (a); // returns n +_Countof (int [7][3]); // returns 7 +@end smallexample + +The result of this operator is an integer constant expression, +unless the array has a variable number of elements. +The operand is only evaluated +if the array has a variable number of elements. +For example: + +@smallexample +_Countof (int [7][n++]); // integer constant expression +_Countof (int [n++][7]); // run-time value; n++ is evaluated +@end smallexample + @node Offsetof @subsection Support for @code{offsetof} @findex __builtin_offsetof