C Support in Clang

Clang implements the following published and upcoming ISO C standards:

Language Standard Flag Available in Clang?
C2y -std=c2y Partial
C23 -std=c23 Partial
C17 -std=c17 Partial
C11 -std=c11 Partial
C99 -std=c99 Clang 17
C89 -std=c89 Yes

The implementation status for C11 and C23 are currently under investigation. Any proposal whose status in Clang is currently unknown will be marked in magenta.

The Clang community is continually striving to improve C standards compliance between releases by submitting and tracking C Defect Reports and implementing resolutions as they become available.

The LLVM bug tracker uses the "c", "c99", "c11", "c17", "c23", and "c2y" labels to track known bugs with Clang's language conformance.

C2y implementation status

Clang has support for some of the features of the C standard following C23, informally referred to as C2y.

You can use Clang in C2y mode with the -std=c2y option (available in Clang 19 and later).

List of features and minimum Clang version with support
Language Feature C2y Proposal Available in Clang?
Sequential hexdigits N3192 Yes
Generic selection expression with a type operand N3260 Clang 17
Round-trip rounding N3232 Yes
Accessing byte arrays N3254 Yes
Slay some earthly demons I N3244
Partial Clang does not document the implementation-defined behavior for decay of an array with the register storage class specifier. Clang does not diagnose an extern inline function with no definition in the TU. Clang accepts and rejects redeclarations with/without an alignment specifier, depending on the order of the declarations.
Support ++ and -- on complex values N3259 Yes
Usability of a byte-wise copy of va_list N3262 Yes
alignof of an incomplete array type N3273 Clang 3.5
Remove imaginary types N3274 Yes
Floating-point exceptions for macro replacements N3286 Yes
Obsolete implicitly octal literals and add delimited escape sequences N3353 No
'if' declarations, v2 N3356 No
Allowing stricter alignment for atomic types N3312 Yes
Slay Some Earthly Demons III N3341 Unknown
Slay Some Earthly Demons IV N3342 Unknown
Slay Some Earthly Demons VI N3344 Unknown
Slay Some Earthly Demons VII N3345 Yes
Slay Some Earthly Demons VIII N3346 Unknown
Introduce complex literals v. 2 N3298 Unknown
Allow zero length operations on null pointers N3322 Yes
How do you add one to something? N3323 Yes
Give consistent wording for SNAN initialization v3 N3364 Unknown
Case range expressions v3.1 N3370 Unknown
New _Lengthof() operator (v4) N3369 No
Named loops, v3 N3355 No

C23 implementation status

Clang has support for some of the features of the C standard following C17, informally referred to as C23.

You can use Clang in C23 mode with the -std=c23 option (available in Clang 18 and later) or with the -std=c2x option (available in Clang 9 and later).

List of features and minimum Clang version with support
Language Feature C23 Proposal Available in Clang?
Evaluation formats N2186 Unknown
Harmonizing static_assert with C++ N2665 Clang 9
nodiscard attribute N2267 Clang 9
maybe_unused attribute N2270 Clang 9
TS 18661 Integration
N2314 Unknown
N2341 No
N2359 No
N2546 No
N2640 Yes
N2755 No
N2931 No
Preprocessor line numbers unspecified N2322
Partial The line number associated with a macro invocation is not the line number of the first character of the macro name in the invocation. Additionally, Clang may not associate the line number of a pp-directive with the first # token. As these are recommended practices and not normative requirements, Clang's behavior is still conforming.
deprecated attribute N2334 Clang 9
Attributes
N2335 Clang 9
N2554 Clang 9
Defining new types in offsetof N2350 Yes
fallthrough attribute N2408 Clang 9
Two's complement sign representation N2412 Clang 14
Adding the u8 character prefix N2418 Clang 15
Remove support for function definitions with identifier lists N2432 Clang 15
Annex F.8 update for implementation extensions and rounding N2384 Unknown
_Bool definitions for true and false N2393 Subsumed by N2935
[[nodiscard("should have a reason")]] N2448 Clang 10
Allowing unnamed parameters in function definitions N2480 Clang 11
Free positioning of labels inside compound statements N2508 Clang 18
Querying attribute support N2553 Clang 9
Binary literals N2549 Clang 9
Allow duplicate attributes N2557 Clang 13
Character encoding of diagnostic text N2563 Yes
What we think we reserve N2572 Partial
Remove mixed wide string literal concatenation N2594 Clang 9
Update to IEC 60559:2020 N2600 Unknown
Compatibility of Pointers to Arrays with Qualifiers N2607
Partial Much of the proposal is implemented, but Clang lacks pedantic diagnostics in C17 and earlier regarding use of incompatible pointer types as an extension. Further, Clang does not properly compute the correct result type for the ?: operator when the result type should be a qualified array type.
Unclear type relationship between a format specifier and its argument N2562 Clang 16
String functions for freestanding implementations N2524 No
Digit separators N2626 Clang 13
Missing +(x) in table N2641 Yes
Add support for preprocessing directives elifdef and elifndef N2645 Clang 13
[[maybe_unused]] for labels N2662 Clang 16
Zeros compare equal N2670 Yes
Negative values N2671 Yes
5.2.4.2.2 cleanup N2672 Yes
Towards Integer Safety N2683 Clang 18
Adding Fundamental Type for N-bit Integers
N2763 Clang 15
N2775 Clang 15
N2969 Clang 15
N3035 Clang 15
#warning directive N2686 Yes
Sterile characters N2686 Yes
Numerically equal N2716 Yes
char16_t & char32_t string literals shall be UTF-16 & UTF-32 N2728 Yes
IEC 60559 binding N2749 Unknown
__has_include for C N2799 Yes
Annex F overflow and underflow N2747 Yes
Remove UB from Incomplete Types in Function Parameters N2770 Yes
Variably-modified types N2778 Yes
Types do not have types N2781 Yes
5.2.4.2.2 cleanup (N2672 update) N2806 Yes
Allow 16-bit ptrdiff_t N2808 Yes
Proposal to update CFP freestanding requirements N2823 Unknown
Types and sizes N2838 Yes
Clarifying integer terms N2837 Yes
Clarification for max exponent macros N2843 Subsumed by N2882
Clarification about expression transformations N2846 Unknown
Contradiction about INFINITY macro N2848 Clang 19
Require exact-width integer type interfaces N2872 Yes
@, $, and ‘ in the source/execution character set N2701 Yes
Quantum exponent of NaN (version 2) N2754 Unknown
The noreturn attribute N2764 Clang 15
*_HAS_SUBNORM==0 implies what? N2797 Yes
Disambiguate the storage class of some compound literals N2819 No
Add annotations for unreachable control flow v2 N2826 Clang 17
Unicode Sequences More Than 21 Bits are a Constraint Violation r0 N2828 Clang 3.6
Identifier Syntax using Unicode Standard Annex 31 N2836 Clang 15
No function declarators without prototypes N2841 Clang 15
Remove default argument promotions for _FloatN types N2844 No
Revised Suggestions of Change for Numerically Equal/Equivalent N2847 Yes
5.2.4.2.2 Cleanup, Again Again (N2806 update) N2879 Yes
char8_t: A type for UTF-8 characters and strings N2653 Clang 19
Clarification for max exponent macros-update N2882 Unknown
Consistent, Warningless, and Intuitive Initialization with {}
N2900 Clang 17
N3011 Clang 17
Not-so-magic: typeof
N2927 Clang 16
N2930 Clang 16
Revise spelling of keywords v7 N2934 Clang 17
Make false and true first-class language features v8 N2935 Clang 15
Properly define blocks as part of the grammar v3 N2937 Yes
Annex X (replacing Annex H) for IEC 60559 interchange N2601 No
Indeterminate Values and Trap Representations N2861 Yes
Remove ATOMIC_VAR_INIT v2 N2886 Clang 17
Require exact-width integer type interfaces v2 N2888 Yes
Wording Change for Variably-Modified Types N2992 Yes
Identifier syntax fixes N2939 Clang 15
Remove trigraphs??! N2940 Clang 18
Improved normal enumerations N3029 Clang 20
Relax requirements for va_start N2975 Clang 16
Enhanced enumerations N3030 Clang 20
Freestanding C and IEC 60559 conformance scope reduction N2951 Unknown
Unsequenced functions N2956 No
Comma ommission and deletion (__VA_OPT__) N3033 Clang 12
Underspecified object definitions N3006 No
Type inference for object declarations N3007 Clang 18
constexpr for object definitions N3018 Clang 19
Introduce storage class specifiers for compound literals N3038 No
Identifier primary expressions N3034 Yes
Introduce the nullptr constant N3042 Clang 17
Memory layout of unions N2929 Yes
Improved tag compatibility N3037 No
#embed N3017 Clang 19

C17 implementation status

There are no major changes in this edition, only technical corrections and clarifications that are tracked by Defect Report.

You can use Clang in C17 mode with the -std=c17 or -std=c18 options (available in Clang 6 and later).

C11 implementation status

Clang implements a significant portion of the ISO 9899:2011 (C11) standard, but the status of individual proposals is still under investigation.

You can use Clang in C11 mode with the -std=c11 option (use -std=c1x in Clang 3.0 and earlier).

List of features and minimum Clang version with support
Language Feature C11 Proposal Available in Clang?
A finer-grained specification for sequencing N1252 Unknown
Clarification of expressions N1282 Yes
Extending the lifetime of temporary objects (factored approach) N1285 No
Requiring signed char to have no padding bits N1310 Yes
Initializing static or external variables N1311 Yes
Conversion between pointers and floating types N1316 Yes
Adding TR 19769 to the C Standard Library N1326 Clang 3.3
Static assertions N1330 Yes
Parallel memory sequencing model proposal N1349 Unknown
_Bool bit-fields N1356 Yes
Technical corrigendum for C1X N1359 Yes
Benign typedef redefinition N1360 Clang 3.1
Thread-local storage N1364 Clang 3.3
Constant expressions N1365 Clang 16
Contractions and expression evaluation methods N1367 Unknown
Floating-point to int/_Bool conversions N1391 Yes
Wide function returns (alternate proposal) N1396
Yes* Clang conforms to this paper on all targets except 32-bit x86 without SSE2. However, Clang does not claim conformance to Annex F on any target and does not intend to ever conform to Annex F on that specific target, so no changes are needed to conform to this paper.
Alignment
N1397 Clang 3.2
N1447 Clang 3.2
Anonymous member-structures and unions (modulo "name lookup") N1406 Yes
Completeness of types N1439 Yes
Generic macro facility N1441 Yes
Dependency ordering for C memory model N1444 Unknown
Subsetting the standard N1460 Yes
Assumed types in F.9.2 N1468 Unknown
Supporting the 'noreturn' property in C1x N1478 Clang 3.3
Updates to C++ memory model based on formalization N1480 Unknown
Explicit initializers for atomics N1482 Clang 4
Atomics proposal (minus ternary op) N1485 Yes
UTF-8 string literals N1488 Clang 3.3
Optimizing away infinite loops N1509 Yes
Conditional normative status for Annex G N1514 Yes (1)
Creation of complex value N1464 Clang 12
Recommendations for extended identifier characters for C and C++ N1518 Unknown
Atomic C1x/C++0x compatibility refinements (1st part only) N1526 Yes
Atomic bitfields implementation defined N1530 Yes
Small fix for the effect of alignment on struct/union type compatibility N1532 Yes
Clarification for wide evaluation N1531 Unknown
(1): Clang does not implement Annex G, so our conditional support conforms by not defining the __STDC_IEC_559_COMPLEX__ macro.

C99 implementation status

Clang implements all of the ISO 9899:1999 (C99) standard.

Note, the list of C99 features comes from the C99 committee draft. Not all C99 documents are publicly available, so the documents referenced in this section may be inaccurate, unknown, or not linked.

You can use Clang in C99 mode with the -std=c99 option.

List of features and minimum Clang version with support
Language Feature C99 Proposal Available in Clang?
restricted character set support via digraphs and <iso646.h> Unknown Yes
more precise aliasing rules via effective type Unknown Yes
restricted pointers N448
Partial Clang's support for restrict is fully conforming but considered only partially implemented. Clang implements all of the constraints required for restrict support, but LLVM only supports restrict optimization semantics for restricted pointers used as function parameters; it does not fully support the semantics for restrict on local variables or data members.
variable length arrays N683 Yes
flexible array members Unknown Yes
static and type qualifiers in parameter array declarators Unknown Yes
complex and imaginary support in <complex.h> N693
Partial Clang supports _Complex type specifiers but does not support _Imaginary type specifiers. Support for _Imaginary is optional in C99 and Clang does not claim conformance to Annex G.

_Complex support requires an underlying support library such as compiler-rt to provide functions like __divsc3. Compiler-rt isn't linked in automatically in MSVC style environments.
type-generic math macros in <tgmath.h> N693 Yes
the long long int type N601 Yes
increase minimum translation limits N590 Clang 3.2
additional floating-point characteristics in <float.h> Unknown Clang 16
remove implicit int
N635 Yes
N692 Yes
N722 Yes
reliable integer division N617 Yes
universal character names (\u and \U) Unknown Yes
extended identifiers N717 Clang 17
hexadecimal floating-point constants N308 Yes
compound literals N716 Yes
designated initializers N494 Yes
// comments N644 Yes
extended integer types and library functions in <inttypes.h> and <stdint.h> Unknown Yes
remove implicit function declaration N636 Yes
preprocessor arithmetic done in intmax_t/uintmax_t N736 Yes
mixed declarations and code N740 Yes
new block scopes for selection and iteration statements Unknown Yes
integer constant type rules N629 Yes
integer promotion rules N725 Yes
macros with a variable number of arguments N707 Yes
IEC 60559 support Unknown
Partial Clang supports much of the language requirements for Annex F, but full conformance is only possible to determine when considering the compiler's language support, the C runtime library's math library support, and the target system's floating-point environment support. Clang does not currently raise an "invalid" floating-point exception on certain conversions, does not raise floating-point exceptions for arithmetic constant expressions, and other corner cases. Note, Clang does not define __STDC_IEC_559__ because the compiler does not fully conform. However, some C standard library implementations ( glibc, musl will define the macro regardless of compiler support unless the compiler defines __GCC_IEC_559, which Clang does not currently define.
Additionally, Clang intentionally will not conform to Annex F on 32-bit x86 without SSE2 due to the behavior of floating-point operations in x87.
trailing comma allowed in enum declaration Unknown Yes
inline functions N741 Yes
boolean type in <stdbool.h> N815 Yes
idempotent type qualifiers N505 Yes
empty macro arguments N570 Yes
additional predefined macro names Unknown Yes
_Pragma preprocessing operator N634 Yes
standard pragmas
N631 Yes
N696 Yes
__func__ predefined identifier N611 Yes
va_copy macro N671 Yes
remove deprecation of aliased array parameters Unknown Yes
conversion of array to pointer not limited to lvalues N835 Yes
relaxed constraints on aggregate and union initialization N782 Clang 3.4
relaxed restrictions on portable header names N772 Yes
return without an expression not permitted in function that returns a value Unknown Yes

C89 implementation status

Clang implements all of the ISO 9899:1990 (C89) standard.

You can use Clang in C89 mode with the -std=c89 or -std=c90 options.