324 "Undeclared identifier 'testFunction' in expression"

General discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
keesdeboer
Posts: 3
Joined: 21 Dec 2012 09:08

324 "Undeclared identifier 'testFunction' in expression"

#1 Post by keesdeboer » 21 Dec 2012 09:53

Dear all,

I've got a problem. I hopeIi can get some tips from you.

I am running the newest version of mikroC PRO for PIC32 v.2.5.1

I am working on a project for a few months now. To keep the project clear, I create sepereate .c files, with their header files. Yestereday I added a new .c and his header file and added them to the project. But this time I ran into a problem. It seems that the compiler, for some odd reason, can't reach those files. When I comile my project i get the error: "Undeclared identifier 'testFunction' in expression".

My code:
Main.c:

Code: Select all

#include "main.h"
//lots of more includes here
#include "testheader.h"

void main()
{
    //lots of functions
    testFunction();
    //more functions;
}
my testFunction.c looks like this:

Code: Select all

#include testFunction.h

void testFunction()
{
    //do something
}
and testFunction.h looks like this:

Code: Select all

#ifndef _TESTFUNCTION_H
#define _TESTFUNCTION_H

//function prototypes
void testFunction(void);

#endif
When I add the content of testFunction.c and testFunction.h in a existing .c and .h file it works fine.

Regards,
Kees

pwdixon
Posts: 1431
Joined: 13 Apr 2005 11:14
Location: UK

Re: 324 "Undeclared identifier 'testFunction' in expression"

#2 Post by pwdixon » 21 Dec 2012 13:09

Could be that you are including the wrong header file?

#include "testheader.h"

keesdeboer
Posts: 3
Joined: 21 Dec 2012 09:08

Re: 324 "Undeclared identifier 'testFunction' in expression"

#3 Post by keesdeboer » 21 Dec 2012 13:45

Thanks for the reply, pwdixon.

I am very certain that I used the correct name for the include file. If I click with my right mouse button on the name of the headerfile, and click in the popup window on 'Find Declaration', the editor opens the headerfile.

So thats why I am very certain.

Regards,
Kees

pwdixon
Posts: 1431
Joined: 13 Apr 2005 11:14
Location: UK

Re: 324 "Undeclared identifier 'testFunction' in expression"

#4 Post by pwdixon » 24 Dec 2012 13:57

keesdeboer wrote:

Code: Select all

#include "main.h"
//lots of more includes here
#include "testheader.h"

void main()
{
    //lots of functions
    testFunction();
    //more functions;
}
so what's "testheader.h"?

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: 324 "Undeclared identifier 'testFunction' in expression"

#5 Post by janko.kaljevic » 24 Dec 2012 16:52

Hello,

I have tested the same situation and it definitely compiles fine.
Please check if the both sources are included in Project Manager, and if the Search paths for header file is correct.

To check this open View->Project Manager, and Project->Edit Search Paths

I assumed that testheader.h is the same as testfunction.h

Best regards.

keesdeboer
Posts: 3
Joined: 21 Dec 2012 09:08

Re: 324 "Undeclared identifier 'testFunction' in expression"

#6 Post by keesdeboer » 28 Dec 2012 20:18

Thank you for the advice, janko.

Because our company is closed for one week (holidays), I am not able to try this out. If I am back, I will try it out.

And yes, testheader.h is the same as testfunction.h (type error from me) :oops:

Regards,
Kees

saveri
Posts: 1
Joined: 23 Jul 2019 08:26

Re: 324 "Undeclared identifier 'testFunction' in expression"

#7 Post by saveri » 25 Jul 2019 07:10

i am getting an error in my mikroc program.
117 324 Undeclared identifier '_LCD_CURSOR_OFF' .
i have done all library of lcd.

// lcd module connections
sbit LCD_RS at P1_7_bit;
sbit LCD_EN at P1_6_bit;

sbit LCD_D4 at P1_5_bit;
sbit LCD_D5 at P1_4_bit;
sbit LCD_D6 at P1_3_bit;
sbit LCD_D7 at P1_2_bit;
// End Lcd module connections

// Define all adc_pins
char ADC_Port at P0;

sbit Add_A at P2_4_bit;
sbit Add_B at P2_5_bit;
sbit Add_C at P2_6_bit;

sbit ALE at P2_7_bit;
sbit EOC at P2_1_bit;
sbit OE at P2_0_bit;
sbit START at P2_2_bit;
sbit CLK at P2_3_bit;
// end Define all adc_pins

char digit1[]="000";
char digit2[]="000";
char digit3[]="000";

unsigned int adc1=0, adc2=0, adc3=0;

unsigned char ADC_Read(unsigned char channel)
{
unsigned int i = 0;
unsigned int ADC_value = 0;
// select channel
switch (channel)
{
case 0: Add_C = 0; Add_B = 0; Add_A = 0; break; //AN0
case 1: Add_C = 0; Add_B = 0; Add_A = 1; break; //AN1
case 2: Add_C = 0; Add_B = 1; Add_A = 0; break; //AN2
case 3: Add_C = 0; Add_B = 1; Add_A = 1; break; //AN3
case 4: Add_C = 1; Add_B = 0; Add_A = 0; break; //AN4
case 5: Add_C = 1; Add_B = 0; Add_A = 1; break; //AN5
case 6: Add_C = 1; Add_B = 1; Add_A = 0; break; //AN6
case 7: Add_C = 1; Add_B = 1; Add_A = 1; break; //AN7
}
Delay_us(10); // 250khz Frequency
ALE = 1; // Enable Address Latch
CLK = 1; //Make CLK High
Delay_us(10); //250khz Frequency
CLK = 0; // Make CLK Low
START = 1; // START ADC Conversion
Delay_us(10); // 250kHz Frequency
CLK = 1; // Make CLK High
ALE = 0; // DISABLE ADDRESS LATCH
Delay_us(10); // 250kHz frequency
CLK = 0; // MAKE CLK LOW
START = 0; // complete the start pulse
for(i=0;i<2000;i++) // 20ms
{
CLK = !CLK; // Toggle Clock
Delay_us(10); // 250khz frequency
if(!EOC) //wait for EOC to be high
break;
}
for(i=0;i<2000;i++) // 20ms
{
CLK = !CLK; // Toggle Clock
Delay_us(10); // 250khz frequency
if(EOC) //WAIT FOR EOC TO BE HIGH
break;
}
CLK = 0; // MAKE CLK LOW
OE = 1; // ENABLE OUTPUT
Delay_us(10); // 250khz frequency
CLK = 1; // MAKE CLK HIGH
Delay_us(10); // 250khz frequency
CLK = 0; // MAKE CLK LOW
Delay_us(10); // 250khz frequency
CLK = 1; // MAKE CLK HIGH

ADC_value = ADC_Port;
Delay_us(10); // 250khz frequency
OE = 0;
CLK = 0;
Delay_us(10); // 250khz frequency

return ADC_value;
}
//
void print_1()
{
digit1[2]= adc1 %10+48;
digit1[1]= (adc1/10) %10+48;
digit1[0]= (adc1/100) %10+48;
Lcd_Out(1,5,digit1);
}
void print_2()
{
digit2[2]= adc2 %10+48;
digit2[1]= (adc2/10) %10+48;
digit2[0]= (adc2/100) %10+48;
Lcd_Out(2,5,digit2);
}
void print_3()
{
digit3[2]= adc3 %10+48;
digit3[1]= (adc3/10) %10+48;
digit3[0]= (adc3/100) %10+48;
Lcd_Out(1,14,digit3);
}

//
void main()
{
Lcd_Init(); // Initialize Lcd
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Out(1,1,"NIKHIL");

Delay_ms(5000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
LCD_Out(1,1,"AN1= AN3= ");
LCD_Out(2,1,"AN2= ");

p1=0x00;
ADC_Port=0xFF; //Make ADC port as input
P2=0x10; //Make all pins of P2 to zero except P2^4, beacuse EOC is connected in that pin,which is input.

while(1)
{
adc1=ADC_Read(1); // read adc channel AN0
print_1();

adc2=ADC_Read(2); // read adc channel AN0
print_2();

adc3=ADC_Read(3); // read adc channel AN0
print_3();


}
}

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: 324 "Undeclared identifier 'testFunction' in expression"

#8 Post by jovana.medakovic » 25 Jul 2019 15:09

Hello,

Can you tell me which MCU you are using?
Also, can you zip and send me your project for review?

Kind regards,
Jovana

Post Reply

Return to “mikroC PRO for PIC32 General”