|
|
View previous topic :: View next topic |
Author |
Message |
Nandus2000
Joined: 17 Sep 2008 Posts: 10
|
Multiple files issue in MPLAB IDE V8.14 with CCS C compiler |
Posted: Tue Sep 23, 2008 6:34 am |
|
|
Hi,
I'm using MPLAB IDE V8.14 with CCS C compiler.
I've created a project for PIC16F877A
I've added A.c and B.c files in the project as follows.
A.C file:
------------------------------------------------------------
Code: | #include <16F877.H>
//Systems include
#include <stdio.h>
//User Includes
#include "B.h"
// Preprocessor directive that defines the chip fuses
#fuses HS,NOWDT,NOPROTECT
// Preprocessor directive that specifies clock speed
#use delay(clock=4M)
// Preprocessor directive that includes RS232 libraries
#use RS232(BAUD=19200, BITS=8, PARITY=N, STOP=1, XMIT=PIN_C6, RCV=PIN_C7, ERRORS)
//User Includes
#include "B.h"
void main(void)
{
int i = 5;
printf("Value of I after additoin = %d\n", myAddFunc(i));
} |
B.C file
------------------------------------------------------------
Code: | //User Includes
#include "B.h"
int myAddFunc(int iData)
{
return( iData+10);
}
|
B.H file
------------------------------------------------------------
Code: | #ifndef B_H
#define B_H
//Prototype.
int myAddFunc(int iData);
#endif |
Unfortunately it generates a build error: Error 112 "A.c" Line 23(1,1): Function used but not defined: ... myAddFunc SCR=825
i.e. error at line: printf("Value of I after additoin = %d\n", myAddFunc(i));
Also I can not compile the file "B.c" individually.
Please could you let me know the solution for this at the earliest?
Thanks,
Nandkishor |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Nandus2000
Joined: 17 Sep 2008 Posts: 10
|
*SOLVED* Multiple files issue. |
Posted: Wed Sep 24, 2008 2:50 am |
|
|
Dear PCM programmer,
Many thanks for your reply.
Yes it is really odd that we need include all relevant ".C" files in the file which contains main() function.
Solution that worked for me:
1. I've added only "A.c" file in the project under Source file folder.
2. Added rest of the source files like "B.c" in the project under Other files.
3. Modified A.c as follows:
Code: |
#include <16F877.H>
//Systems include
#include <stdio.h>
// Preprocessor directive that defines the chip fuses
#fuses HS,NOWDT,NOPROTECT
// Preprocessor directive that specifies clock speed
#use delay(clock=4M)
// Preprocessor directive that includes RS232 libraries
#use RS232(BAUD=19200, BITS=8, PARITY=N, STOP=1, XMIT=PIN_C6, RCV=PIN_C7, ERRORS)
//User Includes
#include "B.C"
void main(void)
{
int i = 5;
printf("Value of I after additoin = %d\n", myAddFunc(i));
}
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|