Project 13: C23 Modern Features Laboratory

A showcase of C23 features including typeof, auto, nullptr, constexpr, attributes, and new library functions.

Quick Reference

Attribute Value
Primary Language C
Alternative Languages None
Difficulty Level 3 - Advanced
Time Estimate See main guide
Knowledge Area Language Standards, Modern C
Tooling GCC 13+, Clang 17+
Prerequisites See main guide

What You Will Build

A showcase of C23 features including typeof, auto, nullptr, constexpr, attributes, and new library functions.

Why It Matters

This project builds core skills that appear repeatedly in real-world systems and tooling.

Core Challenges

  • New type inference → Maps to auto and typeof usage
  • Compile-time evaluation → Maps to constexpr
  • Attribute usage → Maps to [[nodiscard]], [[maybe_unused]], etc.

Key Concepts

  • Map the project to core concepts before you code.

Real-World Outcome

# 1. Type inference with auto and typeof
$ ./c23_demo auto
C23 auto type inference:
  auto x = 42;          // x is int
  auto p = &x;          // p is int*
  auto arr[] = {1,2,3}; // arr is int[3]

C23 typeof operators:
  typeof(x) y = 100;    // y is int (same type as x)
  typeof_unqual(cp) p;  // p is char* (removes const)

# 2. nullptr and constexpr
$ ./c23_demo nullptr
nullptr vs NULL:
  NULL: ((void*)0) - can be confused with integer 0
  nullptr: dedicated null pointer constant (type nullptr_t)

$ ./c23_demo constexpr
constexpr vs const:
  const int x = func(); // Can be runtime value
  constexpr int y = 42; // MUST be compile-time constant

Array with constexpr size:
  constexpr size_t N = 10;
  int arr[N];  // Valid in C23!

# 3. Attributes
$ ./c23_demo attributes
[[nodiscard]] applied:
  error_code result = do_something();  // Warning if ignored!

[[deprecated("use new_func instead")]] applied:
  old_func();  // Compiler warning

[[fallthrough]] in switch:
  No warning for intentional fallthrough

# 4. Compiler compatibility check
$ ./c23_demo compat
Compiler: GCC 14.2.0
C23 support:
  auto: ✓ supported
  typeof: ✓ supported
  nullptr: ✓ supported
  constexpr: ✓ supported
  [[attributes]]: ✓ supported
  #embed: ✗ not yet (GCC 15+)

Implementation Guide

  1. Reproduce the simplest happy-path scenario.
  2. Build the smallest working version of the core feature.
  3. Add input validation and error handling.
  4. Add instrumentation/logging to confirm behavior.
  5. Refactor into clean modules with tests.

Milestones

  • Milestone 1: Minimal working program that runs end-to-end.
  • Milestone 2: Correct outputs for typical inputs.
  • Milestone 3: Robust handling of edge cases.
  • Milestone 4: Clean structure and documented usage.

Validation Checklist

  • Output matches the real-world outcome example
  • Handles invalid inputs safely
  • Provides clear errors and exit codes
  • Repeatable results across runs

References

  • Main guide: PROFESSIONAL_C_PROGRAMMING_MASTERY.md
  • Effective C, 2nd Edition by Robert C. Seacord