AnsweredAssumed Answered

C problem

Question asked by Beh on Oct 10, 2013
Latest reply on Oct 10, 2013 by Clive One
I'm confused

I want to have some .c and .h files like thats in stm libs
I declare variables in .h files and include each one in specific .c file. also all included in main.h file and then include main.h to main.c. but then the compiler error "multiple define" occurs!

01.#ifndef __MAIN_H
02.#define __MAIN_H
03. 
04.#include "stm32f10x.h"
05.#include <stdio.h>
06.#include "config.h"
07.#include "lcd.h"
08.#include "delay.h"
09.#include "icon.h"
10.#include "communication.h"
11. 
12.#define scenario_no 5
13.#define touch_int   GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_5)               
14.#define     idle    1
15.#define     menu    2
16.#define     ON      1
17.#define     OFF     0
18. 
19.u8 mode;
20.u8 i;
21.u8 hour, min, sec;
22. 
23. 
24.u16 time_show [8];
25. 
26.u8 t;
27.
 28.#endif

01.#ifndef __COMM_H
02.#define __COMM_H
03. 
04.#include "stm32f10x.h"
05. 
06.#define device_type_t       0
07.#define get_value_t         1
08.#define set_value_t         2
09.#define error_t                 3
10.#define no_error                0x00
11.#define SLAVE_ID                0x0F
12.#define LPP_TYPE                0x00
13.#define digital_input       0x00
14.#define digital_output  0x01
15.#define digital_value       0x04
16. 
17.#define state1  GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1)   
18.#define state0  GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0)   
19. 
20.#define relay0_status   GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3)   
21.#define relay1_status   GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_4)   
22.#define relay2_status   GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_5)   
23.#define relay3_status   GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_6)   
24.#define relaym_status   GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_2)   
25. 
26.u8 current_scenario;
27.u8 packet_send[17];
28. 
29.void send_array(u8 *packet_send, u8 index);
30.void fill_packet(u8 *packet_send, u8 type);
31. 
32.#endif

Project.axf: Error: L6200E: Symbol current_scenario multiply defined (by communication.o and main.o).

so whats the problem?

Outcomes