cancel
Showing results for 
Search instead for 
Did you mean: 

C problem

_behn4m
Associate II
Posted on October 10, 2013 at 14:33

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!


#ifndef __MAIN_H

#define __MAIN_H


#include ''stm32f10x.h''

#include <stdio.h>

#include ''config.h''

#include ''lcd.h''

#include ''delay.h''

#include ''icon.h''

#include ''communication.h''


#define scenario_no 5

#define touch_int GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_5) 

#define idle 1

#define menu 2

#define ON 1

#define OFF 0


u8 mode;

u8 i;

u8 hour, min, sec;



u16 time_show [8];


u8 t;


#endif

#ifndef __COMM_H

#define __COMM_H


#include ''stm32f10x.h''


#define device_type_t 0

#define get_value_t 1

#define set_value_t 2

#define error_t 3

#define no_error 0x00

#define SLAVE_ID 0x0F

#define LPP_TYPE 0x00

#define digital_input 0x00

#define digital_output 0x01

#define digital_value 0x04


#define state1 GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_1) 

#define state0 GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_0) 


#define relay0_status GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3) 

#define relay1_status GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_4) 

#define relay2_status GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_5) 

#define relay3_status GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_6) 

#define relaym_status GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_2) 


u8 current_scenario;

u8 packet_send[17];


void
send_array(u8 *packet_send, u8 index);

void
fill_packet(u8 *packet_send, u8 type);


#endif

Project.axf: Error: L6200E: Symbol current_scenario multiply defined (by communication.o and main.o). so whats the problem?
1 REPLY 1
Posted on October 10, 2013 at 15:26

so whats the problem?

Don't define physical storage in the .H file, use the ''extern'' prefix there, and define the actual physical storage ONCE in the respective .C file.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..