Error: Identifier redefined

General discussion on mikroC.
Post Reply
Author
Message
romain946
Posts: 1
Joined: 10 Mar 2010 21:14

Error: Identifier redefined

#1 Post by romain946 » 10 Mar 2010 21:18

//definition des variables LED
#define LED_R RA0_bit
#define LED_G RA1_bit
#define LED_B RA2_bit

//definition des variables BP
#define MORE_R !RB0_bit
#define LESS_R !RB1_bit
#define MORE_G !RB2_bit
#define LESS_G !RB3_bit
#define MORE_B !RB4_bit
#define LESS_B !RB5_bit
#define MODE_CHG !RB6_bit
#define OK !RB7_bit



//definitions
unsigned char R;
unsigned char G;
unsigned char B;
unsigned char PWM;
unsigned char SCRUT;
unsigned char MODE;
unsigned char COLOR;
unsigned char SPEED;

void manualMode (void);
void autoMode (void);
void outUpdate(void);
void wait(unsigned char tempo); //tempo de grosso modo 70ms


void main(){
//configuration E/S
TRISB = 0b11111111; //port B en entree uniquement
TRISA = 0b00000000; //port A en sortie uniquement
OPTION_REG = 0b00000111; //Les resistances de PullUp sont activées;TMR0=pas de 256us

//boucle du programme
while(1){
autoMode();
while(!OK){
if(MODE_CHG){
if (MODE==0){
MODE=1;
}
else if (MODE==1){
MODE=0;
}
wait(4); //anti-rebonds soft
while(MODE_CHG);
}
}
if (MODE ==0) manualMode();
else if (MODE ==1) autoMode();
}
}

void manualMode(){
R = 255;
G = 255;
B = 0;

while(!MODE_CHG){
if (PWM==0){
if (LESS_R && R>0) R--;
if (MORE_R && R<255) R++;
if (LESS_G && G>0) G--;
if (MORE_G && G<255) G++;
if (LESS_B && B>0) B--;
if (MORE_B && B<255) B++;

}
outUpdate();
}
}

void autoMode(){
COLOR=0;
R=255;G=0;B=0;
while(!MODE_CHG){
if (PWM==0){
if ((SCRUT%SPEED)==0){
switch (COLOR){
case (0): if(G<255) G++;
else COLOR++;
break;
case (1): if(R>0) R--;
else COLOR++;
break;
case (2): if(B<255) B++;
else COLOR++;
break;
case (3): if(G>0) G--;
else COLOR++;
break;
case (4): if (R<255) R++;
else COLOR++;
break;
case (5): if(B>30) B--;
else COLOR++;
break;
case (6): if(B>0){
B--; G++;
}
else COLOR=0;
}
}
SCRUT++;
if (MORE_R && SPEED>0) SPEED--;
if (LESS_R && SPEED<255) SPEED++;
}
outUpdate();
}
}

void outUpdate(void){
if(PWM<R) LED_R=1;
else LED_R=0;
if(PWM<G) LED_G=1;
else LED_G=0;
if(PWM<B) LED_B=1;
else LED_B=0;
PWM++;
}

void wait(unsigned char tempo){
while(tempo){
TMR0=1;
while(TMR0!=0);
tempo--;
}
}
0 1 mikroCPIC1618.exe -MSF -DBG -pP16F887 -DL -O11111114 -fo4 -N"C:\mer.mcppi" -SP"C:\Program Files\Mikroelektronika\mikroC PRO for PIC\defs\" -SP"C:\Program Files\Mikroelektronika\mikroC PRO for PIC\Uses\P16\" -SP"C:\" "mer.c" "__Lib_Math.mcl" "__Lib_MathDouble.mcl" "__Lib_System.mcl" "__Lib_Delays.mcl" "__Lib_CType.mcl" "__Lib_CString.mcl" "__Lib_CStdlib.mcl" "__Lib_CMath.mcl" "__Lib_Conversions.mcl" "__Lib_Sprinti.mcl" "__Lib_Sprintl.mcl" "__Lib_Time.mcl" "__Lib_Trigonometry.mcl" "__Lib_Button.mcl" "__Lib_Keypad4x4.mcl" "__Lib_Manchester.mcl" "__Lib_OneWire.mcl" "__Lib_PS2.mcl" "__Lib_Sound.mcl" "__Lib_SoftI2C.mcl" "__Lib_SoftSPI.mcl" "__Lib_SoftUART.mcl" "__Lib_ADC_88X.mcl" "__Lib_EEPROM.mcl" "__Lib_FLASH_RW.mcl" "__Lib_I2C_c34.mcl" "__Lib_PWM_c21.mcl" "__Lib_SPI_c345.mcl" "__Lib_UART_c67.mcl" "__Lib_PortExpander.mcl" "__Lib_CANSPI.mcl" "__Lib_CF.mcl" "__Lib_GlcdFonts.mcl" "__Lib_Glcd.mcl" "__Lib_LcdConsts.mcl" "__Lib_Lcd.mcl" "__Lib_RS485.mcl" "__Lib_T6963C.mcl" "__Lib_SPIGlcd.mcl" "__Lib_SPILcd.mcl" "__Lib_SPILcd8.mcl" "__Lib_SPIT6963C.mcl" "__Lib_EthEnc28j60.mcl"
0 1138 Available RAM: 352 [bytes], Available ROM: 8192 [bytes]
0 126 All files Preprocessed in 31 ms
0 122 Compilation Started C
19 392 'R' Identifier redefined C
61 318 Assigning to non-lvalue 'R' C
67 321 Lvalue required C
67 318 Assigning to non-lvalue 'R' C
68 321 Lvalue required C
68 318 Assigning to non-lvalue 'R' C
81 318 Assigning to non-lvalue 'R' C
89 321 Lvalue required C
89 318 Assigning to non-lvalue 'R' C
98 321 Lvalue required C
98 318 Assigning to non-lvalue 'R' C
116 312 Internal error '' C
0 102 Finished (with errors): 10 mars 2010, 20:56:49 mer.mcppi

I did not understand that what it means..
Can any one help me..
Thanks..

User avatar
slavisa.zlatanovic
mikroElektronika team
Posts: 1321
Joined: 07 Apr 2009 09:39

Re: Error: Identifier redefined

#2 Post by slavisa.zlatanovic » 11 Mar 2010 13:52

Hi!

Identifier redefined message means that the same identifier already exists in some unit
in your project.
In your case it's located in the definition (*.c) file for the MCU you're using.

That's why you have to use other name for your variable.

Best regards
Best regards
Slavisa

germen
Posts: 3
Joined: 24 Jan 2014 15:05

Re: Error: Identifier redefined

#3 Post by germen » 27 Jan 2014 15:18

I have the same problem.
in my project I have only two files. The main.c and the microcontroller file (P16F874A.c)
When I try compile the project, too many identifiers declared in P16F874A.c show Message No. 11 (* Identifier redefined) .

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Error: Identifier redefined

#4 Post by filip » 28 Jan 2014 13:34

Hi,

Please, can you attach here the project that demonstrates this issue ?

Regards,
Filip.

Priyanka
Posts: 6
Joined: 09 Jun 2014 05:10

Re: Error: Identifier redefined

#5 Post by Priyanka » 09 Jun 2014 05:32

Hello,

I am experiencing a similar difficulty in my code.

Instead of using inbuilt libraries for ADC, LCD and Keypad, I have built one of my own which includes all.
But I keep getting the "Identifier Redefined" error for all LCD and Keypad function names.

I have unchecked the existing ADC, LCD and Keypad libraries in Library Manager and also tried changing function names. I still get the same error.

Please help me. :?

I am attaching my code:

Code: Select all

#define LCD_DPRT PORTD //LCD DATA PORT
#define LCD_DDDR DDRD //LCD DATA DDR
#define LCD_DPIN PIND //LCD DATA PIN
#define LCD_CPRT PORTC// LCD COMMANDS PORT
#define LCD_CDDR DDRC//LCD COMMANDS DDR
#define LCD_CPIN PINC//LCD COMMANDS PIN
#define LCD_RS  0 //LCD RS
#define LCD_RW  1 //LCD RW
#define LCD_EN  2 //LCD EN
#define KEY_PRT PORTB //KEYBOARD PORT
#define KEY_DDR DDRB  //KEYBOARD DDR
#define KEY_PIN PINB  //KEYBOARD PIN

/*Comments*/
//void lcdCommand(unsigned char cmnd);
//void lcdData(unsigned char info);
//void lcd_init();
//void lcd_gotoxy(unsigned char x, unsigned char y);
//void lcd_print(char * str);
//void LCD_write_string(unsigned char * str);
//unsigned char keypadcall(void);
//void InitADC();
//void delay_us(unsigned int d);
//void delay_ms(unsigned int d);
//unsigned int ReadADC(unsigned short int channel);

/* Comments Ended */

void lcd_Command(unsigned char cmnd)
{
    LCD_DPRT=cmnd;
    LCD_CPRT&=~(1<<LCD_RS);
    LCD_CPRT&=~(1<<LCD_RW);
    LCD_CPRT|=(1<<LCD_EN);
    delay_us(1);
    LCD_CPRT&=~(1<<LCD_EN);
    delay_us(100);

}

void lcdData(unsigned char info)
{
    LCD_DPRT=info;
    LCD_CPRT|=(1<<LCD_RS);
    LCD_CPRT&=~(1<<LCD_RW);
    LCD_CPRT|=(1<<LCD_EN);
    delay_us(1);
    LCD_CPRT&=~(1<<LCD_EN);
    delay_us(100);

}

void lcd_init()
{
    LCD_DDDR= 0XFF;
    LCD_CDDR= 0XFF;
    LCD_CPRT &=~(1<<LCD_EN);
    delay_us(2000);
    lcd_Command(0X38);
    lcd_Command(0x0E);
    lcd_Command(0X01);
    delay_us(2000);
    lcd_Command(0X06);

}

void lcd_gotoxy(unsigned char x, unsigned char y)
{
        unsigned char firstCharAdr[] = {0X80, 0XC0, 0X94, 0XD4},array[10];
        unsigned int i=0;
        lcd_Command(firstCharAdr[y-1] + x-1);
        delay_us(100);
        for(i=0;i<10;i++)
        {
                array[i] = 0;
        }
        i=5;
}

void lcd_print(char * str)
{
        unsigned char i=0;

        while(str[i] != 0)
        {
                lcdData(str[i]);
                i++;
        }
}

void LCD_write_string(unsigned char * str)
{
        int i=0;
        if(str[i] == '\0')
        {
                while(str[i] == '\0')
                i++;
        }
        else;
        while(str[i]!='\0')
        {
                lcdData(str[i]);
                i++;
        }
        lcd_gotoxy(10,1);
        lcd_print("kgF");
        return;
}

unsigned char keypadcall(void)
{

        unsigned char keypad [4][4] =
        {
        {'1', '2', '3', 'A'},
        {'4', '5', '6', 'B'},
        {'7', '8', '9', 'C'},
        {'*', '0', '#', 'D'}
        };
        unsigned char colloc;
        char key_store[20],*key_ptr;
        unsigned int rowloc;
        KEY_DDR = 0XF0;
        KEY_PRT = 0XFF;

        do
        {
                KEY_PRT = KEY_PRT & 0X0F;
                colloc = (KEY_PIN & 0X0F);
        }
        while(colloc != 0X0F);

        do
        {
                do
                {
                        colloc =(KEY_PIN&0X0F);
                }
                while(colloc == 0X0F);
                colloc = (KEY_PIN & 0X0F);
        }
        while(colloc == 0X0F);
        while(1)
        {
                KEY_PRT = 0XEF;
                colloc = (KEY_PIN & 0X0F);
                if(colloc != 0X0F)
                {
                        rowloc = 0;
                        break;
                }

                KEY_PRT = 0XDF;
                colloc = (KEY_PIN & 0X0F);
                if(colloc != 0X0F)
                {
                        rowloc = 1;
                        break;
                }

                KEY_PRT = 0XBF;
                colloc = (KEY_PIN & 0X0F);
                if(colloc != 0X0F)
                {
                        rowloc = 2;
                        break;
                }

                KEY_PRT=0X7F;
            colloc=(KEY_PIN&0X0F);
                if(colloc != 0X0F)
                    rowloc = 3;
                    break;
    }

        if(colloc == 0X0E)
        {
                lcdData(keypad[rowloc][0]);
                return (keypad[rowloc][0]);
        }

        else if(colloc == 0X0D)
        {

                lcdData(keypad[rowloc][1]);
                return (keypad[rowloc][1]);
        }
        else if(colloc == 0X0B)
        {
                lcdData(keypad[rowloc][2]);
                return (keypad[rowloc][2]);
        }
        else
        {
                if(rowloc==3);
                else
                        lcdData(keypad[rowloc][3]);
                return (keypad[rowloc][3]);
    }
}


void InitADC()
{

        ADMUX=(1<<REFS0);
        ADCSRA=(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);
        ADCSRA=(1<<ADIE);
        ADCSRA=(1<<ADATE);
        SFIOR=(0<<ADTS2)|(0<<ADTS1)|(0<<ADTS0);
        ADCSRA=(1<<ADEN);


}

unsigned int ReadADC(unsigned short int channel)
{
        unsigned short int low=0,high=0;
        unsigned int read_me=1,buf;
        unsigned char status, call='0';
        unsigned int i=0,d=10,adc_result=0;
        channel=channel&0b0000111;
        ADMUX|=channel;
        ADCSRA|=(1<<ADSC);
        low=ADCL;
        high=ADCH;
        buf=(ADCH<<8)|ADCL;
        while(buf==0)
        {
                lcd_print("N O    I N P U T");
                ADCSRA|=(1<<ADSC);
        }
        lcd_Command(0x01);
        lcd_gotoxy(1,1);
        lcd_print("Press Enter to");
        lcd_gotoxy(1,2);
        lcd_print("Stop ADC I/P");
        do
        {
                if(buf>read_me)
                {
                        read_me=buf;
                }
                call=keypadcall();
                if(call=='#');
                else
                {
                        lcd_Command(0x01);
                        lcd_gotoxy(1,1);
                        lcd_print("Press Enter to");
                        lcd_gotoxy(1,2);
                        lcd_print("Stop ADC I/P");
                }

        }
        while(call!='#');
        lcd_Command(0x01);
        lcd_gotoxy(1,1);
        return(read_me);
}
MESSAGES/WARNINGS/ERRORS:

0 1 mikrocAVR.exe -MSF -DBG -pATMEGA16 -DL -SSA -O11111114 -fo8 -N"C:\Documents and Settings\PDD.PRIYANKA\My Documents\MicroC\JustToBuild.mcpav" -SP"D:\Priyanka_Work\Softwares\Mikroelektronika\mikroC PRO for AVR\defs\" -SP"D:\Priyanka_Work\Softwares\Mikroelektronika\mikroC PRO for AVR\uses\lte64kw\" -SP"C:\Documents and Settings\PDD.PRIYANKA\My Documents\MicroC\" "JustToBuild.c" "__Lib_Key_Lcd_Adc.c" "__Lib_Math.mcl" "__Lib_MathDouble.mcl" "__Lib_System.mcl" "__Lib_Delays.mcl" "__Lib_CType.mcl" "__Lib_CString.mcl" "__Lib_CStdlib.mcl" "__Lib_CMath.mcl" "__Lib_Sprintf.mcl" "__Lib_Sprinti.mcl" "__Lib_Sprintl.mcl" "__Lib_Button.mcl" "__Lib_EEPROM_eew.mcl" "__Lib_Key_Lcd_Adc.mcl"
0 126 All files Preprocessed in 94 ms
0 122 Compilation Started JustToBuild.c
873 123 Compiled Successfully JustToBuild.c
0 122 Compilation Started __Lib_Key_Lcd_Adc.c
26 393 'lcd_Command' Identifier redefined __Lib_Key_Lcd_Adc.c
38 393 'lcdData' Identifier redefined __Lib_Key_Lcd_Adc.c
50 393 'lcd_init' Identifier redefined __Lib_Key_Lcd_Adc.c
64 393 'lcd_gotoxy' Identifier redefined __Lib_Key_Lcd_Adc.c
77 393 'lcd_print' Identifier redefined __Lib_Key_Lcd_Adc.c
88 393 'LCD_write_string' Identifier redefined __Lib_Key_Lcd_Adc.c
107 393 'keypadcall' Identifier redefined __Lib_Key_Lcd_Adc.c
200 393 'InitADC' Identifier redefined __Lib_Key_Lcd_Adc.c
213 393 'ReadADC' Identifier redefined __Lib_Key_Lcd_Adc.c

0 102 Finished (with errors): 09 Jun 2014, 09:19:44 JustToBuild.mcpav

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Error: Identifier redefined

#6 Post by filip » 10 Jun 2014 10:18

Hi,

Please can you attach your project folder, packed in the ZIP or RAR archive ?

Regards,
Filip.

Priyanka
Posts: 6
Joined: 09 Jun 2014 05:10

Re: Error: Identifier redefined

#7 Post by Priyanka » 11 Jun 2014 09:54

Attaching my code and the library I created.
Attachments
My_Code.rar
(69.02 KiB) Downloaded 278 times
My_Library.rar
(11.41 KiB) Downloaded 253 times

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Error: Identifier redefined

#8 Post by filip » 12 Jun 2014 10:46

Hi,

Please find the project that can be compiled in the attachment.

Regards,
Filip.
Attachments
JustToBuild.rar
(13.51 KiB) Downloaded 477 times

Priyanka
Posts: 6
Joined: 09 Jun 2014 05:10

Re: Error: Identifier redefined

#9 Post by Priyanka » 12 Jun 2014 12:42

Hey Filip,

Thank You Very Much, there is NO ERROR Now. :D :D :D

But my ADC shows NO OUTPUT (On LCD),
I am simulating my circuit on Proteus.

Anyway, thanks for the help man!

Priyanka
Posts: 6
Joined: 09 Jun 2014 05:10

Re: Error: Identifier redefined

#10 Post by Priyanka » 14 Jun 2014 05:42

Hello Filip,

I am stuck again :oops:

I want to make some changes in my library file because I am not getting the desired output. How do I do that?

Currently I am not including my library through Library Manager because doing so causes the previous errors and my code seems to access the library I had sent you in some mysterious way, So how do I make changes to my library and make my main code access it?


Thanks for your help man!

Priyanka
Posts: 6
Joined: 09 Jun 2014 05:10

Re: Error: Identifier redefined

#11 Post by Priyanka » 14 Jun 2014 05:42

:?

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Error: Identifier redefined

#12 Post by filip » 17 Jun 2014 09:17

Hi,

Which display are you using ?

Regards,
Filip.

Post Reply

Return to “mikroC General”