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 CCS Technical Support

multi file compilation

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



Joined: 29 Aug 2007
Posts: 87

View user's profile Send private message

multi file compilation
PostPosted: Thu Feb 22, 2024 11:40 am     Reply with quote

Hi all,

It could be a basic question, but I really need to know if there is any way to make a multi file compilation ( for example two (2) ".c" files and two (2) or more ".h" ), obviously with only one main function...is possible? I'm using the Mplabx V6.05 and CCS 5.112

thanks in advance


Last edited by ralph79 on Thu Feb 22, 2024 11:52 am; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Thu Feb 22, 2024 11:49 am     Reply with quote

Just #include them in the right order. If you look at least half the examples
and many of the posts in the code library have multiple files.
My current main project has 47 files.
ralph79



Joined: 29 Aug 2007
Posts: 87

View user's profile Send private message

PostPosted: Thu Feb 22, 2024 11:53 am     Reply with quote

Ttelmah wrote:
Just #include them in the right order. If you look at least half the examples
and many of the posts in the code library have multiple files.
My current main project has 47 files.


Normally i have big files with several .h files (10/12 units) but i never could it working with several .c files ....
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Fri Feb 23, 2024 12:00 am     Reply with quote

.c and .h are just exensions. They make no difference. It depends what
is in them. If you look at the supplied CCS drivers, these usually have
the actual driver as a .c file, and the prototypes and declarations as the
.h file. The main .c file includes these. So multiple .c files. What you can't
have is multiple projects (so sets of fuses, clock settings and processor
includes). Each of these is a separate build, and will generate a separate
main.
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Feb 23, 2024 6:31 pm     Reply with quote

I've never understood the .c vs .h extensions....as it's ALL C code.
to me a 'driver' should have .dvr , setup stuff .hdr , dotc for 'main()'
OK, I've never taken a C course or fully read any C books( 1/2 of one for 8088 though...)
I do use 'pictype.FZS' for a file that contains all the 'fuses'. Silly PIC18F46K22 has more fuses than instructions, so 'offloading ' the fuses to a separate 'include' file made sense to me. Shortens the real program, save me hours of typing the typos from 2 finger typing.
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Fri Feb 23, 2024 11:00 pm     Reply with quote

THe 'standard' used to be that actual code was in .c files, and the .h
files had the prototypes and data definitions. However a huge amount
of code gets these confused.

Yes, a quick read shows this is in The C Programming Language.
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