函数单独建工程编译正确在SYSBIOS例程中函数参数却不匹.... - TMS320C6748 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 3936|回复: 1

[未解决] 函数单独建工程编译正确在SYSBIOS例程中函数参数却不匹....

[复制链接]

3

主题

3

帖子

1029

积分

金牌会员

Rank: 6Rank: 6

积分
1029
发表于 2020-7-1 16:48:42 | 显示全部楼层 |阅读模式
本帖最后由 godjohsn 于 2020-7-1 16:49 编辑

需求是需要用网口接收数据处理,
我在调试“..\Tronlong\TMS320C6748\1\Demo\SYSBIOS\Application”中TCP_Client这个例程时,
TCP.c文件的void TcpTest(void)函数下加了一个自己写的函数 DATA_CMP

#include "fundefine.h"
#include "vars.h"


void TcpTest(void)
{
      ......

    struct Time_Data Time_word[8];
    struct Sat1_Data Date_word[8];   

   unsigned char DataInput[4];
   unsigned char *pDataTemp = DataInput;

      ......
//-------------test------------//
   DataInput[0] = 0x11;
   DataInput[1] = 0x22;
   DataInput[2] = 0x33;
   DataInput[3] = 0x44;  
//////////////////////////////////
      ......

   DATA_CMP(pDataTemp, &(Time_word[0]), &(Date_word[0]));

      ......

}

编译时出错:
"../TCP.c", line 212: error #169: argument of type "struct Time_Data *" is incompatible with parameter of type "struct Time_Data *"
"../TCP.c", line 212: error #169: argument of type "struct Date_Data *" is incompatible with parameter of type "struct Date_Data *"


函数定义在文件“function.c”中:

#include "vars.h"

      ......

void DATA_CMP(unsigned char *pBuf, struct Time_Data *pTime, struct Date_Data *pDate)
{
        pTime->tword1 = (pBuf[0]>>3);
        pTime->tword2 = ((pBuf[0] & 0x07)<<13) + (pBuf[1]<<5) + (pBuf[4]>>3);
        pDate->dword1 = (pBuf[2]>>3) + 5;
        pDate->dword2 = (pBuf[3]>>3);
}

      ......


结构体变量定义文件"vars.h"如下:

#ifndef VARS_H_
#define VARS_H_

struct Time_Data{
        unsigned char tword1;
        unsigned int  tword2;
        unsigned int  tword3;
      ......

};

struct Date_Data{
        unsigned char >dword1
        unsigned char >dword2
      ......
};

      ......

#endif


函数声明文件在"fundefine.h"中:

#ifndef FUNDEFINE_H_
#define FUNDEFINE_H_

      ......

void DATA_CMP(unsigned char *pBuf, struct Time_Data *pTime, struct Date_Data *pDate);

      ......

#endif

编译时出错:
../TCP.c", line 212: error #169: argument of type "struct Time_Data *" is incompatible with parameter of type "struct Time_Data *"
../TCP.c", line 212: error #169: argument of type "struct Date_Data *" is incompatible with parameter of type "struct Date_Data *"
前后引号里的名字、内容、类型都一样居然还 “incompatible” ?

按理说函数在使用时调用的2个参数:&(Time_word[0]), &(Date_word[0]) 取结构体数组首个地址也没问题

而且,这段函数及相关定义我单独拎出来另写一个工程测试的时候编译是没问题的(反复确认过,在TCP工程中没有对函数DATA_CMP及用到的变量做其他操作),这是什么原因?
是不是跟SYSBIOS有关?该如何解决?

ps:
我用printf语句将两个出问题的首地址输出来:
printf("%x\n", &(Time_word[0]));
printf("%x\n", &(Date_word[0]));
在TCP.c程序中的输出是:
c004e2a8
c004e348
在单独的工程中输出是:
80006730
800067d0


请高人给指点一下什么原因?谢谢!

回复

使用道具 举报

3

主题

852

帖子

3538

积分

创龙

Rank: 8Rank: 8

积分
3538
发表于 2020-8-3 09:25:38 | 显示全部楼层
问题有点奇怪。可以加强制类型转换试试。有结果也可以分享一下。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|嵌入式开发者社区 ( 粤ICP备15055271号

GMT+8, 2024-4-16 22:18 , Processed in 0.035408 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

快速回复 返回顶部 返回列表