View previous topic :: View next topic |
Author |
Message |
paulsherman
Joined: 06 Aug 2004 Posts: 1
|
Linker Problem |
Posted: Fri Aug 06, 2004 8:40 am |
|
|
Hi
I have the compiler CCS PCH C Compiler version 3.180 and I am using it with MPLAB IDE v6.30 and have the following problem.
When I come to build the file it says that I am calling a function that is undefined. I have checked and the procedure is there and its header file is included. I know that it is picking it up from the header file because if I remove the include statement the error comes sooner with a slightly different message saying undefined identifier.
It seems to be just compiling the first file in the project and building the single file. It doesn�t seem to be compiling all of the files then linking them.
Can someone please tell me what I am doing wrong. Do I have to create my own linker file.
Sorry if this is a bit basic, but I have been used to using MSVC++ and having all of this created for me.
Thanks in advance
Paul |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Fri Aug 06, 2004 8:57 am |
|
|
I would guess your trying to use the function before the compiler has seen it. It is all serial. (The compiler that is) If your using it in the main program, but it is physicaly after the main,... this is your problem.
Try using a prototype.
Thats how I get around this problem.
And note that I don't think this is a real "problem"/"bug",.. I think most compilers will do this.
I can't help you any more, without seeing your code.
here is my example
Code: |
//---------------- Prototypes--------------------
void ChkErr(void); //print out any errors that occured
//---------------- MAIN --------------------
void main(void)
{
init:
disable_interrupts(GLOBAL);
setup_adc_ports(NO_ANALOGS);
//========forever loop========
while(1)
{
ChkErr();
}//end while(1)
}//end main
//////////////////////////////////////////////////////////////
////////////////////// Subroutines ///////////////////////////
//////////////////////////////////////////////////////////////
//========= err_chk ===========
void ChkErr(void) //print out any errors that occured
{
int8 chk=0;
if (ERRORS==0){return;} //if no errors jump right back out
for(chk=0;chk<16;chk++)
{
if (bit_test(ERRORS,chk))
{
bit_clear(ERRORS,chk);
fprintf(STDERR,"ERROR(%U): %s.\r\n",chk,error_txt[chk]);
tx_buffer(NACK,sizeof(NACK));
rx_indx_i=rx_indx_o=0;
}
}
}
|
|
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Fri Aug 06, 2004 10:48 am |
|
|
CCS does not compile files separately like what you are use to. You have to include the C files in the main file. |
|
|
|