问题:
我在执行idf.py build编译时遇到了报错error: missing braces around ini
tializer [-Werror=mis
sing-braces]。我搜索了解决方法,发现可以在component.mk上添加CFLAGS +=-Wno-missing-braces 将报错改为报警。我添加上了发现并没有起作用。最后我在CMakeLists.txt 上添加target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-missing-braces")得以解决。参考这个链接中的解决方法viewtopic.php?f=25&t=23244&p=83496&hili ... ces#p83496
想知道这为啥直接在compoment.mk添加CFLAGS不生效?
环境:
硬件环境:ESP32-WROVER-B芯片
软件环境:IDF 版本 v4.4-dev-2825-gb63ec47238
开发环境:
操作系统:Win10
IDE: VS Code
日志:
以下为idf.py build执行的日志,我是通过ccache这一段判断没有生效的。
Code: [Select all] [Expand/Collapse]
- PS F:GooddisplayGxEPD_HDnewepdiyexamplescalendar_demo> idf.py build
- Executing action: all (aliases: build)
- Running ninja in directory f:gooddisplaygxepd_hdnewepdiyexamplescalendar_demobuild
- Executing "ninja all"...
- [1/10] Performing build step for 'bootloader'
- [1/1] cmd.exe /C "cd /D F:GooddisplayGxEPD_HDnewepdiyexamplescalendar_demobuildbootloaderesp-idfesptool_py && C:Usersliangkongde.espressifpython_envidf4.4_py3.6_envScriptspython.exe F:/ESP/esp-idf/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x1000 F:/Gooddisplay/GxEPD_HD/new/epdiy/examples/calendar_demo/build/bootloader/bootloader.bin"
- Bootloader binary size 0x6a10 bytes. 0x5f0 bytes (6%) free.
- [2/8] Building C object esp-idf/FlexLayout/CMakeFiles/__idf_FlexLayout.dir/FlexLayout.c.obj
- FAILED: esp-idf/FlexLayout/CMakeFiles/__idf_FlexLayout.dir/FlexLayout.c.obj
- ccache C:Usersliangkongde.espressiftoolsxtensa-esp32-elfesp-2021r1-8.4.0xtensa-esp32-elfbinxtensa-esp32-elf-gcc.exe -Iconfig -I../components/FlexLayout/include -IF:/ESP/esp-idf/components/newlib/platform_include -IF:/ESP/esp-idf/components/freertos/include -IF:/ESP/esp-idf/components/freertos/port/xtensa/include -IF:/ESP/esp-idf/components/freertos/include/esp_additions -IF:/ESP/esp-idf/components/esp_hw_support/include -IF:/ESP/esp-idf/components/esp_hw_support/include/soc -IF:/ESP/esp-idf/components/esp_hw_support/include/soc/esp32 -IF:/ESP/esp-idf/components/esp_hw_support/port/esp32/. -IF:/ESP/esp-idf/components/heap/include -IF:/ESP/esp-idf/components/log/include -IF:/ESP/esp-idf/components/lwip/include/apps -IF:/ESP/esp-idf/components/lwip/include/apps/sntp -IF:/ESP/esp-idf/components/lwip/lwip/src/include -IF:/ESP/esp-idf/components/lwip/port/esp32/include -IF:/ESP/esp-idf/components/lwip/port/esp32/include/arch -IF:/ESP/esp-idf/components/soc/include -IF:/ESP/esp-idf/components/soc/esp32/. -IF:/ESP/esp-idf/components/soc/esp32/include -IF:/ESP/esp-idf/components/hal/esp32/include -IF:/ESP/esp-idf/components/hal/include -IF:/ESP/esp-idf/components/hal/platform_port/include -IF:/ESP/esp-idf/components/esp_rom/include -IF:/ESP/esp-idf/components/esp_rom/include/esp32 -IF:/ESP/esp-idf/components/esp_rom/esp32 -IF:/ESP/esp-idf/components/esp_common/include -IF:/ESP/esp-idf/components/esp_system/include -IF:/ESP/esp-idf/components/esp_system/port/soc -IF:/ESP/esp-idf/components/esp_system/port/public_compat -IF:/ESP/esp-idf/components/esp32/include -IF:/ESP/esp-idf/components/xtensa/include -IF:/ESP/esp-idf/components/xtensa/esp32/include -IF:/ESP/esp-idf/components/driver/include -IF:/ESP/esp-idf/components/driver/esp32/include -IF:/ESP/esp-idf/components/esp_pm/include -IF:/ESP/esp-idf/components/esp_ringbuf/include -IF:/ESP/esp-idf/components/efuse/include -IF:/ESP/esp-idf/components/efuse/esp32/include -IF:/ESP/esp-idf/components/vfs/include -IF:/ESP/esp-idf/components/esp_wifi/include -IF:/ESP/esp-idf/components/esp_event/include -IF:/ESP/esp-idf/components/esp_netif/include -IF:/ESP/esp-idf/components/esp_eth/include -IF:/ESP/esp-idf/components/tcpip_adapter/include -IF:/ESP/esp-idf/components/esp_phy/include -IF:/ESP/esp-idf/components/esp_phy/esp32/include -IF:/ESP/esp-idf/components/esp_ipc/include -IF:/ESP/esp-idf/components/app_trace/include -IF:/ESP/esp-idf/components/esp_timer/include -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-strategy=memw -O2 -fmacro-prefix-map=F:/Gooddisplay/GxEPD_HD/new/epdiy/examples/calendar_demo=. -fmacro-prefix-map=F:/ESP/esp-idf=IDF -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu99 -Wno-old-style-declaration -D_GNU_SOURCE -DIDF_VER="v4.4-dev-2825-gb63ec47238-dirty" -DESP_PLATFORM -MD -MT esp-idf/FlexLayout/CMakeFiles/__idf_FlexLayout.dir/FlexLayout.c.obj -MF esp-idfFlexLayoutCMakeFiles__idf_FlexLayout.dirFlexLayout.c.obj.d -o esp-idf/FlexLayout/CMakeFiles/__idf_FlexLayout.dir/FlexLayout.c.obj -c ../components/FlexLayout/FlexLayout.c
- ../components/FlexLayout/FlexLayout.c:29:32: error: missing braces around initializer [-Werror=missing-braces]
- #define FlexCacheSizeUndefined (FlexSize){ -1000, -1000 }
- ^
- ../components/FlexLayout/FlexLayout.c:240:28: note: in expansion of macro 'FlexCacheSizeUndefined'
- .lastConstrainedSize = FlexCacheSizeUndefined,
- ^~~~~~~~~~~~~~~~~~~~~~
- ../components/FlexLayout/FlexLayout.c:202:41: error: missing braces around initializer [-Werror=missing-braces]
- static const FlexNode defaultFlexNode = {
- ^
- ../components/FlexLayout/FlexLayout.c:241:1: warning: missing initializer for field 'lastSize' of 'FlexNode' {aka 'const struct FlexNode'} [-Wmissing-field-initializers]
- };
- ^
- ../components/FlexLayout/FlexLayout.c:197:16: note: 'lastSize' declared here
- FlexLength lastSize[2];
- ^~~~~~~~
- ../components/FlexLayout/FlexLayout.c: In function 'flex_markDirty':
- ../components/FlexLayout/FlexLayout.c:29:32: error: missing braces around initializer [-Werror=missing-braces]
- #define FlexCacheSizeUndefined (FlexSize){ -1000, -1000 }
- ^
- ../components/FlexLayout/FlexLayout.c:245:33: note: in expansion of macro 'FlexCacheSizeUndefined'
- node->lastConstrainedSize = FlexCacheSizeUndefined;
- ^~~~~~~~~~~~~~~~~~~~~~
- ../components/FlexLayout/FlexLayout.c: In function 'flex_measureNode':
- ../components/FlexLayout/FlexLayout.c:445:12: error: missing braces around initializer [-Werror=missing-braces]
- return (FlexSize){0,0};
- ^
- { }
- ../components/FlexLayout/FlexLayout.c: In function 'flex_layoutInternal':
- ../components/FlexLayout/FlexLayout.c:468:29: error: missing braces around initializer [-Werror=missing-braces]
- FlexSize resolvedSize = {resolvedWidth, resolvedHeight};
- ^
- { }
- ../components/FlexLayout/FlexLayout.c:469:34: error: missing braces around initializer [-Werror=missing-braces]
- FlexSize resolvedInnerSize = {
- ^
- ../components/FlexLayout/FlexLayout.c:29:32: error: missing braces around initializer [-Werror=missing-braces]
- #define FlexCacheSizeUndefined (FlexSize){ -1000, -1000 }
- ^
- ../components/FlexLayout/FlexLayout.c:501:37: note: in expansion of macro 'FlexCacheSizeUndefined'
- node->lastConstrainedSize = FlexCacheSizeUndefined;
- ../components/FlexLayout/FlexLayout.c:558:35: error: missing braces around initializer [-Werror=missing-braces]
- FlexSize resolvedMarginSize = {resolvedMarginWidth, resolvedMarginHeight};
- ^
- { }
- ../components/FlexLayout/FlexLayout.c:559:36: error: missing braces around initializer [-Werror=missing-braces]
- ^
- { }
- ../components/FlexLayout/FlexLayout.c:806:43: warning: comparison is always false due to limited range of data type [-Wtype-limits] if (violations[j] < 0) {
- ^
- ../components/FlexLayout/FlexLayout.c:1209:15: warning: unused variable 'bottom' [-Wunused-variable
- float bottom = item->result.position[FLEX_TOP] + item->result.size[FLEX_HEIGHT];
- ^~~~~~
- ../components/FlexLayout/FlexLayout.c:1208:15: warning: unused variable 'right' [-Wunused-variable]
- float right = item->result.position[FLEX_LEFT] + item->result.size[FLEX_WIDTH];
- ^~~~~
- cc1.exe: some warnings being treated as errors
- ninja: build stopped: subcommand failed.
- ninja failed with exit code 1
GeSHi © Codebox Plus Extension
组件的CMakeLists.txt文件:
Code: [Select all] [Expand/Collapse]
- idf_component_register(SRCS "FlexLayout.c"
- INCLUDE_DIRS "include")
GeSHi © Codebox Plus Extension
componet.mk文件:
Code: [Select all] [Expand/Collapse]
- #
- # "main" pseudo-component makefile.
- #
- # (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
- CFLAGS +=-Wno-missing-braces
- CPPFLAGS +=-Wno-missing-braces
GeSHi © Codebox Plus Extension
报错的文件只写了一部分:
Code: [Select all] [Expand/Collapse]
- typedef union {
- struct {
- float width;
- float height;
- };
- float size[2;
- } FlexSize;
- #define FlexCacheSizeUndefined (FlexSize){ -1000, -1000 }
GeSHi © Codebox Plus Extension
如果在组件的CMakeLists.txt文件设置上target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-missing-braces")是正常的。
附件为编译正常和编译失败的完整日志:
build_right_log.txt
(14.98 KiB) Downloaded 133 times
build_error_log.txt
(17.39 KiB) Downloaded 121 times