RT-Thread / RT-Thread/rt-thread

当不使用RT_USING_LIBC时,rtthread.h中使用的 va_list 未定义

Open
#7,658 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

v5.1.0
Dominant language
C
Stars
12.2k
Forks
5.4k
Avg merge
4d 12h
Merged PRs (30d)
40

Description

在V5.0.0中,当不使用RT_USING_LIBC时,编译内核文件如clock.c时,出现错误:

include\rtthread.h(643): error: #20: identifier "va_list" is undefined
  1. 检查报错位置代码如下:
int rt_vsprintf(char *dest, const char *format, **va_list** arg_ptr);
  1. va_list是在<stdarg.h>中定义的,根据rtdef.h的内容,可知RTTHREAD内核设计只有在使用RT_USING_LIBC时,才允许使用va_list。如下:
#ifdef RT_USING_LIBC
#include <stdint.h>
#include <stddef.h>
#include <stdarg.h>
#include <sys/types.h>
#endif /* RT_USING_LIBC */
  1. 但是,在rtthread.h中,声明rt_vsprintf等函数时,未进行RT_USING_LIBC的检查。建议增加RT_USING_LIBC检查,如下:
#ifdef RT_USING_LIBC
int rt_vsprintf(char *dest, const char *format, va_list arg_ptr);
int rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args);
#endif

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in include/rtthread.h at the rt_vsprintf and rt_vsnprintf declarations, then compare the RT_USING_LIBC handling in rtdef.h. Reproduce the no-RT_USING_LIBC build involving clock.c and verify that the kernel headers compile without the undefined va_list error.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot, operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.