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

multi-files project

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







multi-files project
PostPosted: Tue May 04, 2004 2:21 am     Reply with quote

Hello,

I use CCS compiler (PCM 3.180) in MPLAB Environment (6.50).
I want to BUILD (make) a project (NOT to compile one file main.c including other files .c) as follows :

#include "file1.h"
#include "file2.h"
// etc...

void main(void)
{
function_DEFINED_in_file1();
function_DEFINED_in_file2();

//etc...

}

I don't include file1.c (file2.c) in the project windows...(even if I include them, it doesn't work anyway)

It looks impossible to proceed as above. The only way to solve this problem looks to include files file1.c (file2.c...) in main.c. But I don't want to do like that. Can anyone tell me what I'm wrong ?? Rolling Eyes

Thanks !
[/b]
Pete Smith



Joined: 17 Sep 2003
Posts: 55
Location: Chester, UK

View user's profile Send private message Visit poster's website MSN Messenger ICQ Number

Re: multi-files project
PostPosted: Tue May 04, 2004 6:05 am     Reply with quote

cyrille wrote:
Hello,

I use CCS compiler (PCM 3.180) in MPLAB Environment (6.50).
I want to BUILD (make) a project (NOT to compile one file main.c including other files .c) as follows :

#include "file1.h"
#include "file2.h"
// etc...

void main(void)
{
function_DEFINED_in_file1();
function_DEFINED_in_file2();

//etc...

}

I don't include file1.c (file2.c) in the project windows...(even if I include them, it doesn't work anyway)





It looks impossible to proceed as above. The only way to solve this problem looks to include files file1.c (file2.c...) in main.c. But I don't want to do like that. Can anyone tell me what I'm wrong ?? Rolling Eyes

Thanks !
[/b]


In your .h file, do you have any function prototypes?

You will need to include the .c files anyway (unless you're #including them in the .h file). When you say you're including them in the project file, you'll also (AFAIK) need to include them in the file you actually compile.

What I do is to have a list of all my commonly used functions in a "prototypes" file. Sometimes, 2 files can refer to functions within each file, so you can't include one before the other, because it'll never compile.

I then #include all of the relevant files from my library of functions.

The main file ends up looking like this...

Code:

#include    <16F877A.h>                                        // We're running on a 16F876
#device    *=16 ADC=10                                                             // Tell compiler that ADC is 10 bits
#fuses       NOWDT,HS, NOPROTECT, NOPUT, NOWRT, NOLVP,NOBROWNOUT// Set the fuses
#use          delay (clock=8000000,restart_wdt)                  // PIC is running at4MHz, restarting WDT when delaying

// --------------------------------------------------------------------------------------------------------------------------

#include    <my_library.h>   // The my Library headers
#include    "defines.h"         // All the defines

#include    <stdlib.h>         // Standard Library
#include    <string.h>         // We want string functions
#include    <input.c>            // and keyboard input

#include    "setup.h"            // Setup config
#include    "globals.c"         // Global variables

#include    <my_sbuff.c>      // Serial buffered I/O routines
#include    <my_mmc.c>         // MMC Functions
#include    <my_fr2464.c>      // I2C functions for the FR2416
#include    <my_8583.c>         // I2C functions for the PCH8583
#include    <my_time.c>         // All the time routines
#include    <my_eeprom.c>      // My e2prom routines
#include    <my_io.c>            // My I/O routines
#include    <my_x10.c>         // My X10 routines
#include    <my_shell.c>      // Shell commands
#include    <my_fat.c>         // Include FAT functions

#include    "inter.c"            // Interrupts
#include    "startup.c"         // Startup functionality

void main(void)
{
....
}


Give it a try and tell us how it went.

Pete.
cyrille
Guest







PostPosted: Tue May 04, 2004 7:21 am     Reply with quote

Indeed with ".c" files included in main it works.

But I'm looking for a modular approach where all objects aren't "visible" from main...

I think I will use the PICC compiler from HT Software. Morever we made tests of code size optimization with this compiler and it look better than the CCS compiler...

Thanks a lot.
Ttelmah
Guest







Re: multi-files project
PostPosted: Tue May 04, 2004 7:23 am     Reply with quote

cyrille wrote:
Hello,

I use CCS compiler (PCM 3.180) in MPLAB Environment (6.50).
I want to BUILD (make) a project (NOT to compile one file main.c including other files .c) as follows :

#include "file1.h"
#include "file2.h"
// etc...

void main(void)
{
function_DEFINED_in_file1();
function_DEFINED_in_file2();

//etc...

}

I don't include file1.c (file2.c) in the project windows...(even if I include them, it doesn't work anyway)

It looks impossible to proceed as above. The only way to solve this problem looks to include files file1.c (file2.c...) in main.c. But I don't want to do like that. Can anyone tell me what I'm wrong ?? Rolling Eyes

Thanks !
[/b]

I'm afraid you are not missing anything. CCS, does not have a seperate linker. It expects all source to exist is the one 'tree' created by the main file, and other files included. It will quite happily compile and link such sub files, but cannot handle seperate sources.

Best Wishes
Kasper



Joined: 14 Jan 2004
Posts: 88
Location: Aurora, Ontario, Canada

View user's profile Send private message Visit poster's website

PostPosted: Tue May 04, 2004 8:28 am     Reply with quote

Has anyone tried the beta version of the linker they mentioned on their site at one point?.. does it do the job?
cyrille
Guest







PostPosted: Tue May 04, 2004 8:29 am     Reply with quote

thanks a lot for your help!

I've just tried PICC Lite (freeware for my pic12F629) and it looks better...(build all separate files possibilities, shorter code size in flash and the configuration file is more useful (all registers/bit in registers defined!!!)
I definitively give up CCS...

Cool
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