Skip to content

[Bug] rt_kprintf 使用 %hhu 格式化 int8_t/uint8_t 时输出错误 #11171

@caoddx

Description

@caoddx

RT-Thread Version

5.2.2

Hardware Type/Architectures

apm32f103vb-miniboard

Develop Toolchain

GCC

Describe the bug

使用的是 rt_vsnprintf_tiny,当 int8_t/uint8_t 变量值在 [0, 0x7f] 区间时输出正确,在 [0x80, 0xff] 区间时输出错误。

下面是测试代码和输出结果:

int8_t  i8 = -1;
uint8_t u8 = 255;
rt_kprintf("i8 = %hhd, u8 = %hhd\n", i8, u8);
rt_kprintf("i8 = %hhu, u8 = %hhu\n", i8, u8);

// output:
// i8 = -1, u8 = -1
// i8 = 4294967295, u8 = 4294967295

Other additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions