请教kei uvision3 的一个错误

[复制链接]
 楼主| yioujie 发表于 2010-12-10 20:27 | 显示全部楼层 |阅读模式
个位大虾,
uchar idata sbuf[10] _at_0x50;

这句怎么会报错呢
C(18): error C129: missing ';' before '_at_0x50'
gaohq 发表于 2010-12-10 21:15 | 显示全部楼层
这一句的前面那一句漏写了   ;
 楼主| yioujie 发表于 2010-12-11 07:51 | 显示全部楼层
Variables may be located at absolute memory locations in your C program

source modules using the _at_ keyword. The usage for this feature is:

type _memory_space_ variable_name _at_ constant;

where:

memory_space is the memory space for the variable. If missing from the

declaration, the default memory space is used. Refer to

“Memory Models” on page 94 for more information about

the default memory space.

type is the variable type.

variable_name is the variable name.

constant is the address at which to locate the variable.

The absolute address following _at_ must conform to the physical boundaries of

the memory space for the variable. The Cx51 compiler checks for invalid

address specifications.
这上面的用法没有分号啊,不过加了分号后不再报错,只是不知at函数用上没....
 楼主| yioujie 发表于 2010-12-11 08:50 | 显示全部楼层
#include<reg52.h>
#define uchar unsigned char
加了这些的啊,我看网上别人绝对地址命令,也这样啊,真不懂。。。
 楼主| yioujie 发表于 2010-12-11 09:10 | 显示全部楼层
The _at_ Keyword
The _at_ keyword allows you to specify the address for uninitialized variables in your C source files. The following example demonstrates how to locate several different variable types using the _at_ keyword.

struct link  {
  struct link idata *next;
  char        code  *test;
};

struct link list idata _at_ 0x40;     /* list at idata 0x40 */
char xdata text[256]   _at_ 0xE000;   /* array at xdata 0xE000 */
int xdata i1           _at_ 0x8000;   /* int at xdata 0x8000 */

void main ( void ) {
  link.next = (void *) 0;
  i1        = 0x1234;
  text [0]  = 'a';
}

解决了,以上是keil 里的注释
我的问题是_at_后面的常量得空一格uchar idata sbuf[10] _at_ 0x50;
keil里的help还真是个好东西啊
airwill 发表于 2010-12-11 09:23 | 显示全部楼层
教训: 写代码要注意格式, 空格也不能随便丢.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

87

帖子

0

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