c - 传输结构时数据不匹配的问题
问题描述
我是 C 的初学者,但我还不明白所有内容。我无法解决对大型程序中使用的代码的警告。从理论上讲,我可以跳过这些问题,因为代码正在运行,但在目标应用程序中我遇到了问题,我认为警告表明了问题的根源(我无法解决它们)。
#include <stdio.h>
#include <string.h>
#include <stdint.h>
typedef struct{
uint8_t Tx[2];
uint8_t Rx[2];
}MessageTypeDef;
MessageTypeDef Data = {
{0x11, 0x22},
{0x33, 0x44}
};
void Print_Frame( MessageTypeDef Msg[]);
int main (void)
{
Print_Frame(Data.Tx);
//Print_Frame(Data.Rx);
return 0;
}
void Print_Frame(MessageTypeDef Msg[])
{
char buffer[100] = {0};
sprintf(buffer," FRAME:%02x%02x|\r\n",(Msg->Tx[0]), (Msg->Tx[1]));
printf("TX VALUE: %s\n",buffer);
}
和错误信息:
E:\Embedded_C\untitled\main.c: In function 'main':
E:\Embedded_C\untitled\main.c:20:17: warning: passing argument 1 of 'Print_Frame' from incompatible pointer type [-Wincompatible-pointer-types]
Print_Frame(Data.Tx);
^~~~
E:\Embedded_C\untitled\main.c:16:6: note: expected 'MessageTypeDef * {aka struct <anonymous> *}' but argument is of type 'uint8_t * {aka unsigned char *}'
void Print_Frame( MessageTypeDef Msg[]);
^~~~~~~~~~~
有什么建议么?
解决方案
推荐阅读
- python - Python:仅用一台笔记本电脑(macOS)测试通过串行端口的通信
- java - Android Studio 中的条件问题
- php - Yii2:未找到“kartik\file\FileInput”类,但我的供应商有它。有什么问题?
- rest - Jenkins http插件使用rest上传文件
- reactjs - 在 react const 中使用枚举
- python - Jupyter 交互未导出到 html 中
- .net - 正则表达式在正则表达式注释中不起作用
- java - Spring Boot Zuul API Gateway 返回 404 响应
- c# - http PostAsync 任务的异步列表导致内部服务器错误
- python - python wsgi日志记录到远程服务器被多次发送