CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Multiple files issue in MPLAB IDE V8.14 with CCS C compiler

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Nandus2000



Joined: 17 Sep 2008
Posts: 10

View user's profile Send private message

Multiple files issue in MPLAB IDE V8.14 with CCS C compiler
PostPosted: Tue Sep 23, 2008 6:34 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Sep 23, 2008 9:30 am     Reply with quote

See the links at the end of this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=35724
Nandus2000



Joined: 17 Sep 2008
Posts: 10

View user's profile Send private message

*SOLVED* Multiple files issue.
PostPosted: Wed Sep 24, 2008 2:50 am     Reply with quote

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));
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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