变量声明冲突 [英] conflicting declarations for variable

查看:185
本文介绍了变量声明冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用GSM调制解调器发送短信msg到将先前的msg发送到GSM调制解调器的号码(即回复短信),我能够检索到电话号码.并存储了电话号码.是一个数组.我还创建了另一个数组来存储味精.但是我读了电话号码.我已将大小限制设置为12的数组也仅包含msg数组的部分元素....后来我发现dat,因为两个数组都已采用了顺序存储位置(即,电话数组在存储位置05B处结束)和msg数组从内存位置05C开始.
因此,为了纠正这个问题,我创建了一个如下所示的函数...

I am using GSM modem to send the text msg to the number who has sent the previous msg to the GSM modem (i.e, REPLY to sms) I am able to retrieve the phone no. and have stored the phone no. is a array. I have also created another array for storing the msg. However wen i read the phone no. array which i have set the limit to size 12 only also includes part of the elements of msg array also.... Later on i found out dat since both the arrays have taken sequential memory locations (i.e, phone array ends at memory location 05B and msg array starts from memory location 05C.
Hence to retify this prob I created a function as below...

lcd_putnstr(13,phone_num_buf); // to check the no. where the msg is being sent.

void lcd_putnstr(unsigned char len, char *str)
{
  unsigned char i = 0;
  while(*str != NULL && i < len)
  {
    lcd_write(*str);
    str++;
    i++;
  }
}


void putnstr(unsigned char len, char *str)
{
  unsigned char i = 0;
  while(*str != NULL && i < len)
  {
    putch(*str);
    str++;
    i++;
  }
}

putnstr(SIZE_OF_PH_NUM, (char* )phone_num);

#define SIZE_OF_PH_NUM 13



已经在需要的地方声明了该函数,但在编译时会由于...
引发错误



have declared the function where ever required but wen i compile it throws an error as...

Error [1098] conflicting declarations for variable and it points to putnstr function..



如何解决此错误????



how this bug can be resolved???

推荐答案

您使用的头文件中可能有一个同名的库例程.尝试将putnstr重命名为不太可能发生冲突的内容,例如put_n_str _
There is probably a library routine with the same name in a header file you use. Try renaming putnstr to something that is unlikely to conflict, like put_n_str_


发生冲突,例如put_n_str_"


这也不能解决问题...我尝试更改函数名称,但是会发生相同的错误..
"There is probably a library routine with the same name in a header file you use. Try renaming putnstr to something that is unlikely to conflict, like put_n_str_"


This also does not solve the issue... i have tried changing the function name but the same error occur..


这篇关于变量声明冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆