完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
嗨,为什么编译者告诉我这个警告:“Mc:C:27:警告:(359)指针类型之间的非法转换”警告来自这一行:或者这行:函数被定义为:Rxbuffer被定义为非常感谢!
以上来自于百度翻译 以下为原文 Hi, Why the compilater says to me this warning : "main.c:27: warning: (359) illegal conversion between pointer types" The warning comes from this line : EUSART_Write_Multicharacter("A001002n") or this line : EUSART_Write_Multicharacter(RxBuffer) The function is defined as : void EUSART_Write_character(unsigned char txData) { while(0 == PIR1bits.TXIF) { } TX1REG = txData; // Write the data byte to the USART. } void EUSART_Write_Multicharacter(unsigned char *txMultiData){ while(*txMultiData) { EUSART_Write_character(*txMultiData); //send character pointed to by txMultiData txMultiData++; //increase pointer location to the next character } } Rxbuffer is defined as volatile unsigned char RxBuffer[MAX_LENGTH]; Thank you very much ! |
|
相关推荐
8个回答
|
|
我猜想:一个引号中的字符串(“A00 1002 n”)可能是由编译器存储在Flash中的,它使它成为非符号字符,而不是无符号字符,指针是不同类型的(一个到ROM,另一个指向RAM)。
以上来自于百度翻译 以下为原文 my guess: a character string in quotes ("A001002n") is probably stored in the FLASH by the compiler which makes it type const unsigned char not unsigned char so the pointers are different types (one to ROM and the other to RAM). |
|
|
|
易失性无符号char rxBuff[Max长度];=未签名的CARYU可以将其转换为函数。=无符号查拉指出。
以上来自于百度翻译 以下为原文 volatile unsigned char RxBuffer[MAX_LENGTH]; volatile unsigned char != unsigned char you can cast it of change the function. const unsigned char != unsigned char as pointed out. |
|
|
|
好的,谢谢。RXBuffer的类型是易失性无符号字符,因为它在中断中使用。我怎样才能解决我的问题?我不能改变RxBuffer的类型。我读到建议在中断中使用易失性类型(但我并不真正理解const和易失性的区别)。我应该阅读更多关于这些类型的信息,但是我应该把所有“无符号字符”的类型写为易失性吗?非常感谢你,祝你今天愉快!:)
以上来自于百度翻译 以下为原文 Ok thank you. The type of RXBuffer is volatile unsigned char because it is used in an interrupt. How can I do to solve my problem ? I cannot change the type of RxBuffer. I read that it was recommended to have volatile type in an interrupt (but I don't really understand the difference between const and volatile... I should read more informations about those types) but should I write the type of all "unsigned char" as volatile ? Thank you very much and have a nice day ! :) |
|
|
|
把它投在函数调用中,以匹配调用所期望的内容
以上来自于百度翻译 以下为原文 cast it in the funtion call to match what the call is expecting EUSART_Write_Multicharacter((unsigned char*)RxBuffer); |
|
|
|
|
|
|
|
在这个案例中,const意味着两件事。只读(正常C)2。在FLASH中,那个位置的数字可以在没有编译器知道的情况下改变值。(如果是一个中断,或者一个端口引脚)如果你把一个易失性数组传递给一个不知道它是易失性的函数,则代码可能不正确地工作。传递一个const到一个函数,不期望const是一个警告,因为没有const它可以写入它。限定符一致,使用最高值,或者转换它们(理解你告诉编译器你理解警告并且忽略它)。
以上来自于百度翻译 以下为原文 const means two things in this case. 1.You will not be writing to it. Read Only (Normal C) 2. It is in flash. volatile the number in that location can change value without the compiler knowing. (ie, an interrupt, or a port pin) if you pass a volatile array to a function that does not know it is volatile it is possible that the code may not work correctly. passing a const to a function the is not expecting a const is a warning since without the const it could write to it. You must either make the qualifiers consistent, Use the Highest one, or cast them (understanding you are telling the compiler that you understand the warning and are ignoring it) |
|
|
|
+ 1是应该指出,铸造一个参数是告诉编译器你理解警告或错误,并承担责任,逾越他们!
以上来自于百度翻译 以下为原文 +1 yes should have pointed out that casting a parameter is telling the compiler you understand the warnings or errors and accept responsibility for overiding them! |
|
|
|
应该是指针的类型不一样的要进行转换类型吧
|
|
|
|
只有小组成员才能发言,加入小组>>
5223 浏览 9 评论
2024 浏览 8 评论
1949 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3198 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2252 浏览 5 评论
767浏览 1评论
654浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
580浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
665浏览 0评论
568浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-15 12:56 , Processed in 1.574928 second(s), Total 93, Slave 76 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号