请看看这是什么原因
#include<pic.h>char a1,a2,a3,a4;
#define DBYTE ((unsigned char volatile *) 0)
void pp(char y){
a1=DBYTE;
a2=DBYTE;
a3=DBYTE;
a4=DBYTE;
}
void main(void){
bank1 static long cc=0x89abcdef;
char x;
x=&cc;
pp(x);
while(1);
}
再picc编译后出现如下的提示
Building TEST3.HEX...
Compiling TEST3.C:
Command line: "D:\HT-PIC\BIN\picc.exe -Gtest3 -D24 -E+ -Etest3.err -PSECTMAP -Mtest3.map -16F877 -ID:\HT-PIC\INCLUDE D:\PROJ1\TEST3.C"
D:\PROJ1\TEST3.C: 13: illegal conversion of pointer to integer (warning)
Build completed successfully.
是不是x被强行转换为整数行指针了,但是它说是非法转换。程序运行没有问题 数据类型转换问题
#include<pic.h>
char a1,a2,a3,a4;
#define DBYTE ((unsigned char volatile *) 0)
void pp(char y){
a1=DBYTE;
a2=DBYTE;
a3=DBYTE;
a4=DBYTE;
}
void main(void){
bank1 static long cc=0x89abcdef;
char x;
x=(char)&cc; /*x 应为char*/
pp(x);
while(1);
}
页:
[1]