View previous topic :: View next topic |
Author |
Message |
ralph79
Joined: 29 Aug 2007 Posts: 87
|
multi file compilation |
Posted: Thu Feb 22, 2024 11:40 am |
|
|
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: 19539
|
|
Posted: Thu Feb 22, 2024 11:49 am |
|
|
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
|
|
Posted: Thu Feb 22, 2024 11:53 am |
|
|
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: 19539
|
|
Posted: Fri Feb 23, 2024 12:00 am |
|
|
.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: 9243 Location: Greensville,Ontario
|
|
Posted: Fri Feb 23, 2024 6:31 pm |
|
|
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: 19539
|
|
Posted: Fri Feb 23, 2024 11:00 pm |
|
|
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. |
|
|
|