#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2010
    Posts
    3
    Rep Power
    0

    Arrow Read the sensor data on switch


    hii this my code :

    my logic is that i have to read the current sensor data on appropriate dip sw.
    for that i define the structure for sensor ,also int Read_sensor_id(int Dip_Switch) for to read sensor data on sw.
    but when i complied the err occoured:

    Error: L6200E: Symbol infor multiply defined (by delay.o and commands.o).
    Error: L6200E: Symbol infor multiply defined (by i2c.o and commands.o).
    Error: L6200E: Symbol infor multiply defined (by sensor.o and commands.o).

    i think logic is ok but somthing wrg in structure....?????????


    Code:
    struct sensor
    {
    	U8 sensr_id;
    	U8 opto_read;
    	 
    }infor;
    
    int Read_sensor_id(int Dip_Switch)
    {
    	int sensor_id;
           Dip_Switch = DIP_SWITCH;    //4bit dipsw
    	switch (Dip_Switch)
    	{
    	case 0:
    		sensor_id = SENSOR_ID0;
    		break;
    
    	case 1:
    		sensor_id = SENSOR_ID1;
    		break;
    	case 2:
    		sensor_id = SENSOR_ID2; 
    
    	default:
    		sensor_id = -1; 
    	break;
    	}
    
    	return sensor_id;
    }
    
    int Read_sensor_current_id(int curr_id)
    {
    	curr_id =  Read_Cassette_id(infor.sensr_id);
    
    	return curr_id; 
    }
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2007
    Posts
    765
    Rep Power
    929
    It sounds like you've defined the "infor" structure in every one your .c files. You need the structure type definition and an 'extern' declaration in a header, then define the variable in only one c file.

    For example

    Code:
    /* data.h */
    struct data_type {
        int field;
    };
    
    extern struct data_type data;
    Code:
    /* data.c */
    #include "data.h"
    
    struct data_type data;
    
    void get_data() {
       data.field = 1;
    }
    Code:
    /* main.c */
    #include "data.h"
    
    void use_data() {
       int value = data.field;
    }
    sub{*{$::{$_}}{CODE}==$_[0]&& print for(%:: )}->(\&Meh);
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2011
    Posts
    4
    Rep Power
    0
    Are you by any chance not using include guards and have multiple inclusion?
    Your header should look like:
    Code:
    #ifndef NAMEOFTHELIB_H
    #define NAMEOFTHELIB_H
    //Your definitions
    #endif

IMN logo majestic logo threadwatch logo seochat tools logo