When it comes to compiling files under Hi-Tech C, there are two methods of doing it. One method is to have a single main.c file, and use #include for all the .c files in the project. Call this the 'one file with multiple #include of c files' method.
The second method, also the one usually recommended by C programmers, is to have lots of individual .obj files, and link them at the end. Call this the 'lots of .obj files' method.
For the 'one giant file' method, in MPLab under 'node properties', select 'PIC C compiler' for the root node. For the 'lots of .obj files' method, select 'PIC C linker' for the root node.
The advantages of the 'one file with multiple #include of c files' method
Produces smaller .hex file for a large compiled program. For the 16F876/7, there is 8k of program, divided into 4 pages. A psect cannot cross a page boundary. Sometimes there is wasted space before the end of each page boundary. Because the linker has access to all the functions at once, it does a really good job of fitting them in. Try it yourself - get a large (~8k, ~5000 line) program, and it will be smaller using this method.
The advantages of the 'lots of .obj files' method
What do you think? email support@microchipc.com.
-----Original Message-----
From: Graham Harrison [mailto:]
Sent: Thursday, 15 February 2001 9:59 p.m.
To: support@microchipc.com
Subject: one giant file
Shane
I sometimes use an ICEPIC Jnr for debugging, and I've noticed that single stepping doesn't seem to work across files which have been linked, but works fine within the main() loop.
Graham
-----Original Message-----
From: Ivan Cenov [mailto:okto7@botev.ttm.bg]
Sent: Thursday, 29 March 2001 2:26 a.m.
To: support@microchipc.com
Subject: one giant file
Shane,
I think that one giant file should be used when there is space problems only. I prefer 'lots of obj files' method. This makes my life easier. I can distribute my functions in different files depending on their purpose. And if something is lost, the rest is still available.
There is a third method between 'giant file' and 'lots of obj files': One main file which #includes lots of source files. This method serves good input to the linker while the programmer still has the opportunity to divide source code by the purpose.
But there is no good things without bad things. Try to simulate that code in MPLAB. MPLAB does not want to switch to the included sources. It traces only main #including file.
Search More Tips Here
Ivan Cenov
The second method, also the one usually recommended by C programmers, is to have lots of individual .obj files, and link them at the end. Call this the 'lots of .obj files' method.
For the 'one giant file' method, in MPLab under 'node properties', select 'PIC C compiler' for the root node. For the 'lots of .obj files' method, select 'PIC C linker' for the root node.
The advantages of the 'one file with multiple #include of c files' method
Produces smaller .hex file for a large compiled program. For the 16F876/7, there is 8k of program, divided into 4 pages. A psect cannot cross a page boundary. Sometimes there is wasted space before the end of each page boundary. Because the linker has access to all the functions at once, it does a really good job of fitting them in. Try it yourself - get a large (~8k, ~5000 line) program, and it will be smaller using this method.
The advantages of the 'lots of .obj files' method
- This method supports libraries (ie: in MPLab under 'Edit Project, the 'library path' box is enabled.
- This method supports incremental compiles, which saves a little time, as long as the correct path is entered
What do you think? email support@microchipc.com.
-----Original Message-----
From: Graham Harrison [mailto:
Sent: Thursday, 15 February 2001 9:59 p.m.
To: support@microchipc.com
Subject: one giant file
Shane
I sometimes use an ICEPIC Jnr for debugging, and I've noticed that single stepping doesn't seem to work across files which have been linked, but works fine within the main() loop.
Graham
-----Original Message-----
From: Ivan Cenov [mailto:okto7@botev.ttm.bg]
Sent: Thursday, 29 March 2001 2:26 a.m.
To: support@microchipc.com
Subject: one giant file
Shane,
I think that one giant file should be used when there is space problems only. I prefer 'lots of obj files' method. This makes my life easier. I can distribute my functions in different files depending on their purpose. And if something is lost, the rest is still available.
There is a third method between 'giant file' and 'lots of obj files': One main file which #includes lots of source files. This method serves good input to the linker while the programmer still has the opportunity to divide source code by the purpose.
But there is no good things without bad things. Try to simulate that code in MPLAB. MPLAB does not want to switch to the included sources. It traces only main #including file.
Search More Tips Here
Ivan Cenov
No comments:
Post a Comment