Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KEIL AC6编译警告!!! #64

Open
libangy opened this issue Aug 15, 2022 · 11 comments
Open

KEIL AC6编译警告!!! #64

libangy opened this issue Aug 15, 2022 · 11 comments

Comments

@libangy
Copy link

libangy commented Aug 15, 2022

环境:KEIL5.29
编译器:AC6.13.1
FreeRTOS: V10.4.6,task.c中已增加uxSizeOfStack

cmb_cfg.h:

#define cmb_println(...) printf(VA_ARGS);printf("\r\n");/* e.g., printf(VA_ARGS);printf("\r\n") */

#define CMB_USING_OS_PLATFORM
#define CMB_OS_PLATFORM_TYPE CMB_OS_PLATFORM_FREERTOS

#define CMB_CPU_PLATFORM_TYPE CMB_CPU_ARM_CORTEX_M4
/* enable dump stack information /
#define CMB_USING_DUMP_STACK_INFO
/
language of print information */
#define CMB_PRINT_LANGUAGE CMB_PRINT_LANGUAGE_ENGLISH // (default) or CMB_PRINT_LANGUAGE_CHINESE */

编译出现30个警告:
cm_backtrace.c(168): warning: format string is not a string literal (potentially insecure) [-Wformat-security]
cmb_println(print_info[PRINT_MAIN_STACK_CFG_ERROR]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cmb_cfg.h(35): note: expanded from macro 'cmb_println'
#define cmb_println(...) printf(VA_ARGS);printf("\r\n");/* e.g., printf(VA_ARGS);printf("\r\n") /
^~~~~~~~~~~
cm_backtrace.c(168): note: treat the string as an argument to avoid this
cmb_println(print_info[PRINT_MAIN_STACK_CFG_ERROR]);
^
"%s",
cmb_cfg.h(35): note: expanded from macro 'cmb_println'
#define cmb_println(...) printf(VA_ARGS);printf("\r\n");/
e.g., printf(VA_ARGS);printf("\r\n") /
^
cm_backtrace.c(256): warning: format string is not a string literal (potentially insecure) [-Wformat-security]
cmb_println(print_info[PRINT_THREAD_STACK_INFO]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cmb_cfg.h(35): note: expanded from macro 'cmb_println'
#define cmb_println(...) printf(VA_ARGS);printf("\r\n");/
e.g., printf(VA_ARGS);printf("\r\n") */
^~~~~~~~~~~
../Middlewares/CmBacktrace/cm_backtrace/cm_backtrace.c(256): note: treat the string as an argument to avoid this
……

有什么办法可以消除这些警告吗????@armink

@zhang-4411
Copy link

请问解决了吗

@zhang-4411
Copy link

全部改成宏定义解决

@q164129345
Copy link

我也碰到同样的问题.....能详细说一下解决方案吗??

@zhang-4411
Copy link

zhang-4411 commented Dec 5, 2022

AC6
#define PRINT "ABC"
const char *str1 = "ABC";
printf("str1 ");//warning
printf("%s",str1 );//no warning
printf("PRINT " );//no warning
/*****************************************************************************/
#define PRINT_MAIN_STACK_CFG_ERROR "ERROR: Unable to get the main stack information, please check the configuration of the main stack"
#define PRINT_FIRMWARE_INFO "Firmware name: %s, hardware version: %s, software version: %s"
#define PRINT_ASSERT_ON_THREAD "Assert on thread %s"
#define PRINT_ASSERT_ON_HANDLER "Assert on interrupt or bare metal(no OS) environment"
#define PRINT_THREAD_STACK_INFO "===== Thread stack information ====="
....................................................................

@q164129345
Copy link

3Q......这也是一种思路。

@q164129345
Copy link

我发现,就算用宏定义清除了警告。。。在AC6上还是不正常,打印出来的信息不正常。。。

@libangy
Copy link
Author

libangy commented Dec 6, 2022

解决方案:Option for Targets -> C/C++(AC6) -> Misc Controls -> -Wno-format-security

@q164129345
Copy link

image

很奇怪的是...换成AC6之后的打印有问题。。。

@q164129345
Copy link

解决方案:Option for Targets -> C/C++(AC6) -> Misc Controls -> -Wno-format-security
警告消除了。。。但是打印的信息有问题了。。
image

@xjtuecho
Copy link

xjtuecho commented Mar 17, 2023

为了支持中文显示搞的东西,这种库完全没有必要支持中文显示。我给清理了一下,去掉了中文支持,兼容了C89,剩4个文件,解压后丢到自己的工程中即可。很好用,不需要文档,直接看代码即可。
cm_backtrace.zip

@wdfk-prog
Copy link

或许跟编码格式有关系,使用GB2312的中文可能不正常.UTF8格式的中文试一下或许可以

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants