We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
你好我注册了如下函数 int func(int i, char ch, char *str, float d) { float daniel = 123.456; printf("input int: %d, char: %c, string: %s float:%f\r\n", i, ch, str, d); return 100; } SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), func, func, test);
走读代码,对回调函数时,类型判断不是很理解: int (*func)(size_t, size_t, size_t, size_t) = command->data.cmd.function; ret = func(params[0], params[1], params[2], params[3]);
params[3]是size_t类型,但里面存放的是float型的二进制数据 在给回调函数喂参数时,按我理解是按照size_t类型来解释内存数据的,最终转换成的应该也是个整数呢 怎么实际会变成float型呢?
还有个问题,我发现多加了行打印,实际调用func的时候,float型打印就不对了 int (*func)(size_t, size_t, size_t, size_t) = command->data.cmd.function; printf("%u, %u, %u, %u\n", params[0], params[1], params[2], params[3]); ret = func(params[0], params[1], params[2], params[3]);
The text was updated successfully, but these errors were encountered:
浮点数据直接解析是大概率会有问题的,可以参考下这个 https://nevermindzzt.github.io/2020/04/17/letter-shell%E4%BB%A3%E7%90%86%E5%87%BD%E6%95%B0%E8%A7%A3%E6%9E%90/
Sorry, something went wrong.
No branches or pull requests
你好我注册了如下函数
int func(int i, char ch, char *str, float d)
{
float daniel = 123.456;
printf("input int: %d, char: %c, string: %s float:%f\r\n", i, ch, str, d);
return 100;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), func, func, test);
走读代码,对回调函数时,类型判断不是很理解:
int (*func)(size_t, size_t, size_t, size_t) = command->data.cmd.function;
ret = func(params[0], params[1], params[2], params[3]);
params[3]是size_t类型,但里面存放的是float型的二进制数据
在给回调函数喂参数时,按我理解是按照size_t类型来解释内存数据的,最终转换成的应该也是个整数呢
怎么实际会变成float型呢?
还有个问题,我发现多加了行打印,实际调用func的时候,float型打印就不对了
int (*func)(size_t, size_t, size_t, size_t) = command->data.cmd.function;
printf("%u, %u, %u, %u\n", params[0], params[1], params[2], params[3]);
ret = func(params[0], params[1], params[2], params[3]);
The text was updated successfully, but these errors were encountered: