keil问题

[复制链接]
1948|5
 楼主| hsbjb 发表于 2014-3-28 18:36 | 显示全部楼层 |阅读模式
帮忙看看怎么回事吧。
用KEIL写一个小程序
int a = 0x0001;
unsigned char *p;
p = &a;
结果最后一句编译不过去,提示不能赋值
main.c(131): error:  #513: a value of type "int *" cannot be assigned to an entity of type "un signed char *"

同样的程序在wintc就能通过正常运行,不知道是不是编译器哪里有限制,用的STM32f103的片子。
baidudz 发表于 2014-3-28 19:41 | 显示全部楼层
不同环境的编译器对运行安全的检查级别和要求不一样
火箭球迷 发表于 2014-3-28 19:46 | 显示全部楼层
你定义的int型数据要用int型的指针来获取数据地址吧?
无冕之王 发表于 2014-3-28 19:58 | 显示全部楼层
int a = 0x0001;
unsigned char *p;
p = (unsigned char *)&a;
angerbird 发表于 2014-4-21 22:34 | 显示全部楼层
楼上的正解的。。支持一下
firstblood 发表于 2014-4-22 19:30 | 显示全部楼层
两种变量的类型定义不一致所致
您需要登录后才可以回帖 登录 | 注册

本版积分规则

193

主题

2354

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部