# C Support

[中文]

ESP-IDF is primarily written in C and provides C APIs. ESP-IDF can use one of the following C Standard Library implementations:

- Newlib (default)

- Picolibc (enabled with CONFIG_LIBC_PICOLIBC Kconfig option)

The Newlib version is specified in esp_libc/sbom.yml.

In general, all C features supported by the compiler (currently GCC) can be used in ESP-IDF, unless otherwise noted in Unsupported C Features below.

## C Version

GNU dialect of ISO C23 (`--std=gnu23`) is the current default C version in ESP-IDF.

To compile the source code of a certain component using a different language standard, set the desired compiler flag in the component's `CMakeLists.txt` file:

    idf_component_register( ... )
    target_compile_options(${COMPONENT_LIB} PRIVATE -std=gnu11)

If the public header files of the component also need to be compiled with the same language standard, replace the flag `PRIVATE` with `PUBLIC`.

## Unsupported C Features

The following features are not supported in ESP-IDF.

### Nested Function Pointers

The GNU dialect of ISO C23 supports nested functions. However, ESP-IDF does not support referencing nested functions as pointers. This is due to the fact that the GCC compiler generates a trampoline (i.e., small piece of executable code) on the stack when a pointer to a nested function is referenced. ESP-IDF does not permit executing code from a stack, thus use of pointers to nested functions is not supported.

Was this page helpful?

- Thank you! We received your feedback.
- If you have any comments, fill in Espressif Documentation Feedback Form.

- We value your feedback.
- Let us know how we can improve this page by filling in Espressif Documentation Feedback Form.