mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
docs: Added C documentation page
Closes https://github.com/espressif/esp-idf/issues/12439 Closes https://github.com/espressif/esp-idf/issues/12001
This commit is contained in:
parent
526aa01154
commit
ed5a7dfa82
36
docs/en/api-guides/c.rst
Normal file
36
docs/en/api-guides/c.rst
Normal file
@ -0,0 +1,36 @@
|
||||
C Support
|
||||
===========
|
||||
|
||||
:link_to_translation:`zh_CN:[中文]`
|
||||
|
||||
.. highlight:: cpp
|
||||
|
||||
ESP-IDF is primarily written in C and provides C APIs. `Newlib <https://sourceware.org/newlib/>`_ is used as standard C library (the Newlib version can be found in :component_file:`newlib/sbom.yml`). In general, all C features supported by the compiler, currently GCC, should be available in ESP-IDF, unless specified in :ref:`unsupported_c_features` below.
|
||||
|
||||
.. _c_version:
|
||||
|
||||
C Version
|
||||
---------
|
||||
|
||||
**GNU dialect of ISO C17** (``--std=gnu17``) 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:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
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:
|
||||
|
||||
Unsupported C Features
|
||||
----------------------
|
||||
|
||||
The following features are not supported in ESP-IDF.
|
||||
|
||||
Nested Function Pointers
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The **GNU dialect of ISO C17** supports `nested functions <https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html>`_. However, they do not work in ESP-IDF when referenced as function pointer because the compiler generates a trampoline on the stack, while the stack is not executable in ESP-IDF. Hence, do not use function pointers to nested functions.
|
@ -12,8 +12,9 @@ API Guides
|
||||
bootloader
|
||||
build-system
|
||||
:SOC_SUPPORT_COEXISTENCE: coexist
|
||||
core_dump
|
||||
c
|
||||
cplusplus
|
||||
core_dump
|
||||
current-consumption-measurement-modules
|
||||
:SOC_RTC_MEM_SUPPORTED: deep-sleep-stub
|
||||
:SOC_USB_OTG_SUPPORTED: dfu
|
||||
|
1
docs/zh_CN/api-guides/c.rst
Normal file
1
docs/zh_CN/api-guides/c.rst
Normal file
@ -0,0 +1 @@
|
||||
.. include:: ../../en/api-guides/c.rst
|
@ -12,8 +12,9 @@ API 指南
|
||||
bootloader
|
||||
build-system
|
||||
:SOC_SUPPORT_COEXISTENCE: coexist
|
||||
core_dump
|
||||
c
|
||||
cplusplus
|
||||
core_dump
|
||||
current-consumption-measurement-modules
|
||||
:SOC_RTC_MEM_SUPPORTED: deep-sleep-stub
|
||||
:SOC_USB_OTG_SUPPORTED: dfu
|
||||
|
@ -129,7 +129,7 @@ function(__build_set_lang_version)
|
||||
if(NOT IDF_TARGET STREQUAL "linux")
|
||||
# Building for chip targets: we use a known version of the toolchain.
|
||||
# Use latest supported versions.
|
||||
# Please update docs/en/api-guides/cplusplus.rst and
|
||||
# Please update docs/en/api-guides/c.rst, docs/en/api-guides/cplusplus.rst and
|
||||
# tools/test_apps/system/cxx_build_test/main/test_cxx_standard.cpp when changing this.
|
||||
set(c_std gnu17)
|
||||
set(cxx_std gnu++2b)
|
||||
|
Loading…
x
Reference in New Issue
Block a user