File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed
Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -249,7 +249,9 @@ C2y Feature Support
249249 a conforming extension in earlier C language modes, but not in C++ language
250250 modes (``std::extent `` and ``std::size `` already provide the same
251251 functionality but with more granularity). The feature can be tested via
252- ``__has_feature(c_countof) `` or ``__has_extension(c_countof) ``.
252+ ``__has_feature(c_countof) `` or ``__has_extension(c_countof) ``. This also
253+ adds the ``<stdcountof.h> `` header file which exposes the ``countof `` macro
254+ which expands to ``_Countof ``.
253255
254256C23 Feature Support
255257^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change 1+ /*===---- stdcountof.h - Standard header for countof -----------------------===
2+ *
3+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+ * See https://llvm.org/LICENSE.txt for license information.
5+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+ *
7+ *===-----------------------------------------------------------------------===
8+ */
9+
10+ #ifndef __STDCOUNTOF_H
11+ #define __STDCOUNTOF_H
12+
13+ #define countof _Countof
14+
15+ #endif /* __STDCOUNTOF_H */
Original file line number Diff line number Diff line change 1- // RUN: %clang_cc1 -fsyntax-only -std=c2y -verify %s
1+ // RUN: %clang_cc1 -fsyntax-only -std=c2y -verify -ffreestanding %s
22
33/* WG14 N3469: Clang 21
44 * The Big Array Size Survey
55 *
6- * This renames _Lengthof to _Countof.
6+ * This renames _Lengthof to _Countof and introduces the stdcountof.h header .
77 */
88
99void test () {
@@ -12,3 +12,12 @@ void test() {
1212 expected-error {{expected expression}}
1313}
1414
15+ #ifdef countof
16+ #error "why is countof defined as a macro?"
17+ #endif
18+
19+ #include <stdcountof.h>
20+
21+ #ifndef countof
22+ #error "why is countof not defined as a macro?"
23+ #endif
You can’t perform that action at this time.
0 commit comments