CodeBlanks Logo Icon CodeBlanks

C11 and C17

Learn the C11 and C17 standards.

The C11 standard

C11 (ISO/IEC 9899:2011) is the modern version of C. Following C99, this revision added several important features: atomic operations (stdatomic.h), threads (threads.h), type-based selection (_Generic) and compile-time checks (_Static_assert).

These features bring C up to speed for modern systems programming. Atomics enable lock-free data structures; threads enable standard parallel programming. You compile with -std=c11 or -std=c17.

The C17 bug-fix revision

C17 (ISO/IEC 9899:2018) is a bug-fix revision of C11. It adds no new language features; it only fixes defects and ambiguities in C11. For this reason C17 is fully compatible with C11.

In practice C17 is the recommended version today. Compiling with -std=c17 -pedantic helps you write portable, clean code. The __STDC_VERSION__ macro is 201112L for C11 and 201710L for C17, so you can detect which standard you compile with.

Practice Print the standard version

Using #if __STDC_VERSION__ >= 201112L, write an int main(void) that prints "Modern C" for modern C (C11 and later), otherwise "Eski C". Use #if, #else and #endif.

Starter code

main.c
#include <stdio.h>

// Standart sürümünü denetle:
// modern C ise "Modern C" yazdır
// değilse "Eski C" yazdır

Sample solution

main.c
#include <stdio.h>

int main(void) {
#if __STDC_VERSION__ >= 201112L
    printf("Modern C\n");
#else
    printf("Eski C\n");
#endif
    return 0;
}

Expected output

Modern C

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which standard introduced the stdatomic.h header?

  • C11 Correct answer
  • C99
  • C89
  • C17

Explanation: stdatomic.h arrived with C11; atomics were added then.

2 Complete the C17 version macro

Question
#if __STDC_VERSION__ >= ____
    printf("C17\n");
#endif
Answer
#if __STDC_VERSION__ >= 201710L
    printf("C17\n");
#endif

Explanation: For C17, __STDC_VERSION__ holds 201710L.

3 Match standard to feature

Term Meaning
C11 Atomic operations
C17 Bug fixes
C99 Single-line // comments
C89 First C standard

All lessons in Expert