Skip to content

Commit 36eea21

Browse files
committed
tests/lib/cpp/cxx: remove inline comments from DTS-generated headers
The DTS extraction process generates headers with inline comments, which are not ignored properly by the C++ preprocessor. This is causing build failures when using devicetree macros in C++ code. Add a note to the C++ documentation to inform users about the issue and how to work around it, and update the C++ test case. Signed-off-by: Luca Burelli <[email protected]>
1 parent bdb2ac1 commit 36eea21

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

doc/develop/languages/cpp/index.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,17 @@ The C++ standard requires the ``main()`` function to have the return type of
3636
has to be selected. Zephyr ignores the return value from main, so applications
3737
should not return status information and should, instead, return zero.
3838

39+
If you need to access data from the device tree in C++ files, add the following
40+
argument to the ``west build`` command to prevent compile-time macro expansion
41+
issues:
42+
43+
.. code-block:: console
44+
45+
EXTRA_GEN_DEFINES_ARGS=--no-inline-comments
46+
3947
.. note::
40-
Do not use C++ for kernel, driver, or system initialization code.
48+
49+
Do not use C++ for kernel, driver, or system initialization code.
4150

4251
Language Features
4352
*****************

tests/lib/cpp/cxx/testcase.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ common:
44
integration_platforms:
55
- mps2/an385
66
- qemu_cortex_a53
7+
extra_args:
8+
- EXTRA_GEN_DEFINES_ARGS=--no-inline-comments
79

810
tests:
911
cpp.main.minimal:

0 commit comments

Comments
 (0)