我想创建一个函数,该函数将采用可变数量的不同类型的参数。我的问题是如何解析参数类型。就像调用者可以以任何顺序传递任何类型的参数(不指定格式说明符)。所以在调用函数中我如何区分类型。
如何打印函数 var_argument 中调用者传递的所有值?
假设我想在调用者传递的参数的 var_argument 函数中执行 sprintf
这是我的 C 代码
#include <stdio.h>
#include <stdarg.h>
void var_argument(int num,...);
int main()
{
var_argument(3,"Hello",7.87f,6);
var_argument(3,7.87f,"Hello",6);
return 0;
}
void var_argument(int num,...)
{
char str[80];
/* What code should I write to differentiate between types and to print all the values passed by the caller */
va_list list;
va_start(list,num);
/* How to do sprintf of the parameter passed to this function and store
the formatted output in the array str */
}
Run Code Online (Sandbox Code Playgroud) 为什么SRC_URI即使我们在FILESEXTRAPATHS_prepend变量中包含文件路径,也需要给出文件路径。喜欢:
SUMMARY = "Simple Hello application"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI = "file://Hello_1.c \
file://Hello_2.c \
"
do_compile() {
oe_runmake
}
do_install() {
install -d ${D}${bindir}
install -m 0755 Hello ${D}${bindir}
}
Run Code Online (Sandbox Code Playgroud)
在文件文件夹中,我有两个文件hello1.c和hello2.c。当我删除SRC_URI它时,输出以下错误,
ERROR: Hello-1.0-r0 do_compile: oe_runmake failed
Run Code Online (Sandbox Code Playgroud)
但是,如果我删除
FILESEXTRAPATHS_prepend它,则工作正常。
变量的目的是FILESEXTRAPATHS_prepend什么?
为什么SRC_URI即使在其中包含文件路径的情况下删除,也会出现错误FILESEXTRAPATHS_prepend?
我有一个文件夹,其中有太多的c文件(约200 c文件)
现在在该文件夹的bitbake文件中,我在SRC_URI变量中添加文件,如下所示:
SRC_URI = "file://filename_1.c \
file://filename_2.c \
.
.
.
file://filename_n.c \
Run Code Online (Sandbox Code Playgroud)
因为我有太多的c文件,所以很难在bitbake的SRC_URI变量中添加这样的文件.什么是将所有c文件包含在bitabake文件中的最短方法.或者有没有办法添加c文件的目录,它将包括该目录中存在的所有c文件.
请帮忙