[已解决] cc1.exe: some warnings being treated as errors

Yobooy_
Posts: 4
Joined: Mon Sep 13, 2021 9:59 am

[已解决] cc1.exe: some warnings being treated as errors

Postby Yobooy_ » Mon Sep 13, 2021 11:01 am

描述:从STM32移植QRCODE库到ESP32,编译报错:警告被当做错误处理。
环境:1.windows7,编译器是eclipse (QRCODE库在KEIL上编译和运行没问题);
2.SDK是esp-idf-v4.3(无分支);
3.硬件ESP32-WROVER-IE。
补充说明:报错处是个 带嵌套的一维结构体数组,(error: missing braces around initializer [-Werror=missing-braces])详见下图。
请教:1.能否消除这个警告? 2.如不能消除 如何忽略这个警告?
Attachments
miss.jpg
警告截图
miss.jpg (12.38 KiB) Viewed 6583 times
结构体.jpg
结构体截图
结构体.jpg (41.68 KiB) Viewed 6583 times
结构体数组.png
结构体数组截图
结构体数组.png (62.01 KiB) Viewed 6583 times

ESP_Gargamel
Posts: 786
Joined: Wed Nov 14, 2018 8:45 am

Re: cc1.exe: some warnings being treated as errors

Postby ESP_Gargamel » Thu Sep 16, 2021 9:33 am

不知道你是如何管理 qrcode 的,如果这个是做成一个 component 的话,可以在这个下面的 CMakeLists.txt 上添加:

Code: Select all

target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-missing-braces")
忽略这个 error

Yobooy_
Posts: 4
Joined: Mon Sep 13, 2021 9:59 am

Re: cc1.exe: some warnings being treated as errors

Postby Yobooy_ » Thu Sep 16, 2021 11:08 am

对的 component添加库的 按你的方式已经成功忽略了警告,编译通过了。十分感谢你!!!!

Yobooy_
Posts: 4
Joined: Mon Sep 13, 2021 9:59 am

Re: cc1.exe: some warnings being treated as errors

Postby Yobooy_ » Thu Sep 16, 2021 11:10 am

有一个疑问哈:这样忽略警告的方式 通过编译 算不算作弊呀 对程序的长期运行有影响吗

ESP_Gargamel
Posts: 786
Joined: Wed Nov 14, 2018 8:45 am

Re: cc1.exe: some warnings being treated as errors

Postby ESP_Gargamel » Fri Sep 17, 2021 3:00 am

这个和编译器行为有些关系,具体有没有影响,这个和应用场景有关,不能绝对保证。但一般如果你当前没问题的话,应该影响不大。

Yobooy_
Posts: 4
Joined: Mon Sep 13, 2021 9:59 am

Re: cc1.exe: some warnings being treated as errors

Postby Yobooy_ » Fri Sep 17, 2021 11:01 am

好的好的 再次感谢您 预祝中秋快乐!!

Who is online

Users browsing this forum: No registered users and 70 guests