硬汉嵌入式论坛

 找回密码
 立即注册
查看: 536|回复: 1
收起左侧

[J-Link] RTT打印类型问题,unsigned int正常,uint32_t有警告

[复制链接]

22

主题

40

回帖

106

积分

初级会员

积分
106
发表于 2024-12-20 11:32:10 | 显示全部楼层 |阅读模式
正常:
    unsigned int test = 1234;
    printf("Running...%u\n", test);


警告:
    uint32_t test = 1234;
    printf("Running...%u\n", test);

    format '%u' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]

请问是什么原因,怎么解决呢


回复

使用道具 举报

22

主题

40

回帖

106

积分

初级会员

积分
106
 楼主| 发表于 2024-12-20 13:14:50 | 显示全部楼层
本帖最后由 eoorosy 于 2024-12-20 13:15 编辑

哦吼,是开了全部警告,所以报了,可以使用<inttypes.h>

    uint32_t test = 1234;
    printf("Running...%" PRIu32 "\n", test);


或者禁用

-Wno-format

这样就不报了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-6-10 04:22 , Processed in 0.236224 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表