首页 » 技术SOS » 嵌入式系统 » 关于定义结构体变量的问题

关于定义结构体变量的问题

菜鸟
2008-05-10 21:36:18
我正在用arm和spc3做一个profibus的从站,我的结构体是像下面这样定义的。 typedef struct /* SPC3的1.5KRAM空间定义 */ { /******************************************* 处理器参数区(详细情况可以参见SPC3手册) ********************************************/ union { uint w; uchar b[2]; } int_req; /* 0x00-0x01:中断请求寄存器 */ union { union { ulong w; uchar b[2]; } com; /* 中断寄存器(可读) */ union { ulong w; uchar b[2]; } ack; /* 中断接受寄存器(可写) */ } int_reg; /* 0x02-0x03:中断寄存器 */ union { ulong mask; /* 中断屏蔽寄存器(可写) */ uchar status[2]; /* 状态寄存器(可读) */ } is_reg; /* 0x04-0x05:中断屏蔽寄存器和状态寄存器 */ ulong mode_reg0; /* 0x06-0x07:模式寄存器0 */ union { struct { uchar din_buffer_sm; /* 0x08 */ uchar new_din_buf_cmd; /* 0x09 */ uchar dout_buffer_sm; /* 0x0a */ uchar next_dout_buf_cmd; /* 0x0b */ } r; /* 可读 */ struct { uchar mode_reg1_s; /* 0x08 */ uchar mode_reg1_r; /* 0x09 */ uchar wd_baud_ctrl_val; /* 0x0a */ uchar mintsdr_val; /* 0x0b */ } w; /* 可写 */ } x1; /* 0x08-0x0b:可设置参数读写单元 */ uchar diag_buffer_sm; /* 0x0c */ uchar new_diag_buffer_cmd; /* 0x0d */ uchar user_prm_data_ok; /* 0x0e */ uchar user_prm_data_nok; /* 0x0f */ uchar user_cfg_data_ok; /* 0x10 */ uchar user_cfg_data_nok; /* 0x11 */ uchar user_ddb_prm_data_ok; /* 0x12 */ uchar user_ddb_prm_data_nok; /* 0x13 */ uchar ssa_buffer_free_cmd; /* 0x14 */ uchar reserved_15; /* 0x15 */ /*********************************************** 组织参数区 ***********************************************/ uchar r_ts_adr; /* 0x16 */ uchar r_fdl_sap_list_ptr; /* 0x17 */ ulong r_user_wd_value; /* 0x18 */ uchar r_len_dout_buf; /* 0x1a */ uchar r_dout_buf_ptr[3]; /* 0x1b */ uchar r_len_din_buf; /* 0x1e */ uchar r_din_buf_ptr[3]; /* 0x1f */ uchar r_len_ddbout_buf; /* 0x22 */ uchar r_ddbout_buf_ptr; /* 0x23 */ uchar r_len_diag_buf[2]; /* 0x24 */ uchar r_diag_buf_ptr[2]; /* 0x26 */ uchar r_len_cntrl_buf[2]; /* 0x28 */ uchar r_aux_buf_sel; /* 0x2a */ uchar r_aux_buf_ptr[2]; /* 0x2b */ uchar r_len_ssa_buf; /* 0x2d */ uchar r_ssa_buf_ptr; /* 0x2e */ uchar r_len_prm_buf; /* 0x2f */ uchar r_prm_buf_ptr; /* 0x30 */ uchar r_len_cfg_buf; /* 0x31 */ uchar r_cfg_buf_ptr; /* 0x32 */ uchar r_len_read_cfg_buf; /* 0x33 */ uchar r_read_cfg_buf_ptr; /* 0x34 */ uchar r_len_ddb_prm_buf; /* 0x35 */ uchar r_ddb_prm_buf_ptr; /* 0x36 */ uchar r_score_exp; /* 0x37 */ uchar r_score_error; /* 0x38 */ uchar r_real_no_add_change; /* 0x39 */ uchar r_ident_low; /* 0x3a */ uchar r_ident_high; /* 0x3b */ uchar r_gc_command; /* 0x3c */ uchar r_len_spec_prm_buf; /* 0x3d */ uchar reserved_3e_3f[2]; /* 0x3e-0x3f */ /*************************************** 用户区 ***************************************/ uchar user[1472]; /* 0x40-:用户区 */ } SPC3; volatile struct SPC3 *ptspc3 = (struct SPC3*)0X83000000;//080510 但是用ADS编译之后,出现了很多的错误如下: Warning : C2207W: inventing 'extern int delay();' DP.c line 215 Warning : C2207W: inventing 'extern int ARMDisableIRQ();' DP.c line 219 Error : (Serious) C2363E: member 'int_req' not found in 'struct SPC3' DP.c line 221 Error : (Serious) C2363E: member 'is_reg' not found in 'struct SPC3' DP.c line 228 Error : (Serious) C2363E: member 'r_user_wd_value' not found in 'struct SPC3' DP.c line 240 Error : (Serious) C2363E: member 'r_ident_high' not found in 'struct SPC3' DP.c line 258 Error : (Serious) C2363E: member 'r_ident_low' not found in 'struct SPC3' DP.c line 259 Error : (Serious) C2363E: member 'r_ts_adr' not found in 'struct SPC3' DP.c line 260 Error : (Serious) C2363E: member 'mode_reg0' not found in 'struct SPC3' DP.c line 261 Error : (Serious) C2363E: member 'r_real_no_add_change' not found in 'struct SPC3' DP.c line 262 Error : (Serious) C2363E: member 'user' not found in 'struct SPC3' DP.c line 263 Error : (Serious) C2363E: member 'r_read_cfg_buf_ptr' not found in 'struct SPC3' DP.c line 275 Error : (Serious) C2363E: member 'r_len_read_cfg_buf' not found in 'struct SPC3' DP.c line 277 Warning : C2207W: inventing 'extern int iic_show();' DP.c line 298 Error : (Serious) C2363E: member 'x1' not found in 'struct SPC3' DP.c line 303 Error : (Serious) C2363E: member 'r_din_buf_ptr' not found in 'struct SPC3' DP.c line 303 Error : (Serious) C2363E: member 'x1' not found in 'struct SPC3' DP.c line 303 Error : (Serious) C2363E: member 'diag_buffer_sm' not found in 'struct SPC3' DP.c line 308 Error : (Serious) C2363E: member 'r_diag_buf_ptr' not found in 'struct SPC3' DP.c line 308 Error : (Serious) C2363E: member 'diag_buffer_sm' not found in 'struct SPC3' DP.c line 308 Error : (Serious) C2363E: member 'r_diag_buf_ptr' not found in 'struct SPC3' DP.c line 308 Error : (Serious) C2363E: member 'is_reg' not found in 'struct SPC3' DP.c line 313 Error : (Serious) C2363E: member 'x1' not found in 'struct SPC3' DP.c line 315 Error : (Serious) C2363E: member 'x1' not found in 'struct SPC3' DP.c line 317 Error : (Serious) C2363E: member 'is_reg' not found in 'struct SPC3' DP.c line 341 Error : (Serious) C2363E: member 'is_reg' not found in 'struct SPC3' DP.c line 342 Error : (Serious) C2363E: member 'r_real_no_add_change' not found in 'struct SPC3' DP.c line 369 Error : (Serious) C2363E: member 'r_len_spec_prm_buf' not found in 'struct SPC3' DP.c line 407 Error : (Serious) C2363E: member 'r_len_spec_prm_buf' not found in 'struct SPC3' DP.c line 411 Error : (Serious) C2363E: member 'user' not found in 'struct SPC3' DP.c line 415 Error : (Serious) C2363E: member 'r_aux_buf_sel' not found in 'struct SPC3' DP.c line 423 Error : (Serious) C2363E: member 'r_aux_buf_sel' not found in 'struct SPC3' DP.c line 426 Error : (Serious) C2947E: Illegal types for operands: '-' DP.c line 427 Error : (Fatal) C3047U: Too many errors DP.c line 430 我是按照ads安装的说明里面这么定义的结构体,但是结果怎么会找不到里面的变量呢?????请各位给我解答一下。。。我做了好多天了,一直没有解决。。。谢谢!!!
分享
关键词: 结构体, 变量  
高工
2022-10-16 22:12:59
1楼

先整理一下再发出来吧