首页 > 解决方案 > 传输结构时数据不匹配的问题

问题描述

我是 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[]);
      ^~~~~~~~~~~

有什么建议么?

标签: cfunctionstruct

解决方案


推荐阅读