C Support in Clang

Clang implements the following published and upcoming ISO C standards:

Language Standard Flag Available in Clang?
C89 -std=c89 Yes
C99 -std=c99 Almost certainly
C11 -std=c11 Probably
C17 -std=c17 Maybe?
C2x -std=c2x Partial

The implementation status for C99, C11, and C17 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", and "c2x" labels to track known bugs with Clang's language conformance.

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.

C99 implementation status

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

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 Unknown
more precise aliasing rules via effective type Unknown Unknown
restricted pointers N448 Unknown
variable length arrays N683 Yes
flexible array members Unknown Yes
static and type qualifiers in parameter array declarators Unknown Yes
more precise aliasing rules via effective type Unknown Unknown
complex and imaginary support in <complex.h>
N620 Unknown
N638 Unknown
N657 Unknown
N694 Unknown
N809 Unknown
type-generic math macros in <tgmath.h> N693 Yes
the long long int type N601 Yes
increase minimum translation limits N590 Unknown
additional floating-point characteristics in <float.h> Unknown Unknown
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 Unknown
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 Unknown
integer constant type rules N629 Yes
integer promotion rules N725 Yes
macros with a variable number of arguments N707 Yes
IEC 60559 support Unknown Unknown
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 Unknown
new structure type compatibility (tag compatibility) N522 Unknown
additional predefined macro names Unknown Unknown
_Pragma preprocessing operator N634 Yes
standard pragmas
N631 Unknown
N696 Unknown
__func__ predefined identifier N611 Yes
va_copy macro N671 Yes
LIA compatibility annex N792 No
remove deprecation of aliased array parameters Unknown Unknown
conversion of array to pointer not limited to lvalues Unknown Unknown
relaxed constraints on aggregate and union initialization Unknown Unknown
relaxed restrictions on portable header names N772 Unknown
return without an expression not permitted in function that returns a value Unknown Yes

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 Unknown
Extending the lifetime of temporary objects (factored approach) N1285 Unknown
Requiring signed char to have no padding bits N1310 Unknown
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
Analyzability (#1, #4 - conditionally normative) N1350 Unknown
FLT_EVAL_METHOD issues (first change only) N1353 Unknown
_Bool bit-fields N1356 Yes
Technical corrigendum for C1X N1359 Unknown
Benign typedef redefinition N1360 Clang 3.1
Thread-local storage N1364 Clang 3.3
Constant expressions N1365 Unknown
Contractions and expression evaluation methods N1367 Unknown
FLT_EVAL_METHOD and return N1382 Unknown
Floating-point to int/_Bool conversions N1391 Yes
Analyzability (along the lines) N1394 Unknown
Wide function returns (alternate proposal) N1396 Unknown
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 Unknown
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 Unknown
Creation of complex value N1464 Unknown
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
Synthesis re _Atomic N1537 Unknown
Clarification for wide evaluation N1531 Unknown

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).

C2x implementation status

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

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

List of features and minimum Clang version with support
Language Feature C2x Proposal Available in Clang?
Evaluation formats N2186 Unknown
Clarifying the restrict Keyword v2 N2660 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 Unknown
N2401 Unknown
N2359 No
N2546 Unknown
N2580 Unknown
N2640 Unknown
N2755 Unknown
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
*_IS_IEC_60559 feature test macros N2379 Unknown
Floating-point negation and conversion N2416 Unknown
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 16
Clarification request for C17 example of undefined behavior N2517 No
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
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
Adding Fundamental Type for N-bit Integers
N2763 Clang 15
N2775 Clang 15
N2969 Clang 15
N3035 Unknown
#warning directive N2686 Yes
Sterile characters N2686 Yes
Integer constant expressions N2713 No
Numerically equal N2716 Yes
char16_t & char32_t string literals shall be UTF-16 & UTF-32 N2728 Unknown
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 Unknown
Clarifying integer terms N2837 Yes
Clarification for max exponent macros N2843 Unknown
Clarification about expression transformations N2846 Unknown
Contradiction about INFINITY macro N2848 Unknown
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 Unknown
Add annotations for unreachable control flow v2 N2826 No
Unicode Sequences More Than 21 Bits are a Constraint Violation r0 N2828 Clang 3.6
Make assert() macro user friendly for C and C++ v2 N2829 No
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 Unknown
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 No
Clarification for max exponent macros-update N2882 Unknown
Consistent, Warningless, and Intuitive Initialization with {}
N2900 Unknown
N3011 Unknown
Not-so-magic: typeof
N2927 Clang 16
N2930 Clang 16
Type annex tgmath narrowing macros with integer args v2 N2931 Unknown
Revise spelling of keywords v7 N2934 No
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 No
Require exact-width integer type interfaces v2 N2888 Yes
Wording Change for Variably-Modified Types N2992 Yes
Identifier syntax fixes N2939 Unknown
Remove trigraphs??! N2940 Yes
Improved normal enumerations N3029 Unknown
Relax requirements for va_start N2975 Clang 16
Enhanced enumerations N3030 Unknown
Freestanding C and IEC 60559 conformance scope reduction N2951 Unknown
Unsequenced functions N2956 No
Comma ommission and deletion (__VA_OPT__) N3033 Unknown
Underspecified object definitions N3006 Unknown
Type inference for object declarations N3007 No
constexpr for object definitions N3018 No
Introduce storage class specifiers for compound literals N3038 No
Identifier primary expressions N3034 Yes
Introduce the nullptr constant N3042
Partial Parts of the implementation may be incorrect until WG14 has completed NB comment resolution for incompatibilities with C++ that were discovered. The major use cases and usage patterns should work well, though.
Memory layout of unions N2929 Yes
Improved tag compatibility N3037 No
#embed N3017 No