我想要画按钮,就定义了一个按钮结构体,并且定义了几个结构体变量数组,结果编译时出现问题,先看代码
该段代码位于GUI.H里
- #ifndef _gui_h
- #define _gui_h
- #include "STM32f10x.h"
- #include "lcd.h"
- #define Radius 30
- #define Main_height 40
- #define Main_width 100
- #define Main_x 120
- #define Main_y 60
- #define Main_w_color RED
- #define Main_b_color YELLOW
- #define Main_w_size 16
- #define Main_r_color BLACK
- #define BUTTONNUM 10
- typedef struct
- {
- u16 x;//按钮中心点X坐标
- u16 y;
- u16 width;//按钮宽度
- u16 height;//按钮高度
- u16 word_color;//字颜 {MOD}
- u16 button_color;//按钮颜 {MOD}
- u16 rec_color;//边框颜 {MOD}
- u8 size;//字大小
- u8 *string;//按钮显示文字
- }Button_Typedef;
- Button_Typedef ButtonX[BUTTONNUM];
- void GUI_Init(void);
- void DrawButton(Button_Typedef*);
- void Button_DeInit(void);
- void MenuButton_Init(void);
- void Button_Init(u8,Button_Typedef *);
- #endif
复制代码编译结果如下:
- Build target 'LCD'
- compiling main.c...
- main.c(47): warning: #177-D: variable "key_num" was declared but never referenced
- KEY_NUM key_num,key_num_buf;
- main.c(47): warning: #177-D: variable "key_num_buf" was declared but never referenced
- KEY_NUM key_num,key_num_buf;
- main.c(49): warning: #177-D: variable "i" was declared but never referenced
- u8 i=0;
- main.c(50): warning: #177-D: variable "release_key" was declared but never referenced
- u8 release_key=1;
- main.c(51): warning: #177-D: variable "loop_cnt" was declared but never referenced
- u32 loop_cnt=0;
- main.c: 5 warnings, 0 errors
- compiling GUI.c...
- linking...
- ..OBJLCD.axf: Error: L6200E: Symbol ButtonX multiply defined (by gui.o and main.o).
- Not enough information to list image symbols.
- Not enough information to list the image map.
- Finished: 2 information, 0 warning and 1 error messages.
- "..OBJLCD.axf" - 1 Error(s), 5 Warning(s).
- Target not created.
- Build Time Elapsed: 00:00:03
复制代码我去网上查了下,有人说是RAM超出了,我发现RAM还有很大富余。
另外如果我将
Button_Typedef ButtonX[BUTTONNUM];这一句放在MAIN.C里面编译就不出错。
但是我想把这个定义放到GUI.H里。
请问问题出在哪里?看编译结果的话,说是ButtonX重复定义了,但是其实并没有,我将这个变量名改成其他的也不行。
一周热门 更多>