View previous topic :: View next topic |
Author |
Message |
zhzhou Guest
|
Compiler Options |
Posted: Mon Sep 08, 2008 2:48 pm |
|
|
I am having problems with the compiler including all functions, even if they are not in use. For example, I have included a FAT32 driver, but I'm not using all the functions. The PCH compiler is including everything. This is for a bootloader so I want to occupy minimal code space. For larger programs, I notice that the compiler knows not to include unused functions.
Is there a compiler option I can turn on to not include unused functions?
Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Sep 08, 2008 2:55 pm |
|
|
Post a link to the FAT32 code that you're using. If it's from the CCS
code library, then post a link to it.
Post a list of the routines that you believe are improperly being
included in the compiled program (and in the HEX file).
Post your PIC and your compiler version. |
|
|
zhzhou Guest
|
|
Posted: Mon Sep 08, 2008 3:15 pm |
|
|
I'm using PCH v4.069 with MPLAB and compiling for PIC18F65J90.
It doesn't actually matter if it's FAT32 or LCD or whatever driver. I have a program that can compile. Then when I add one line: #include "fat32.c", the compiler says ROM usage is 28% (it was 2% before the include). I don't even call any functions within fat32.c in the mainline code. The hexfile also increases from 6kB to 28kB. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Sep 08, 2008 3:41 pm |
|
|
I installed vs. 4.069 and I compiled two test files. The first one does not
have any #include'd driver file. The 2nd test has the LCD.c file included.
The .LST file for both tests shows the same thing: 30 bytes of ROM.
This is compiled under MPLAB.
This is the first test, without the LCD.c file:
Code: | #include <18F65J90.h>
#fuses HS, NOWDT
#use delay(clock=20000000)
//================================
void main()
{
while(1);
}
CCS PCH C Compiler, Version 4.069, xxxxx 08-Sep-08 14:29
Filename: 18F65J10.lst
ROM used: 30 bytes (0%)
Largest free fragment is 32730
RAM used: 5 (0%) at main() level
5 (0%) worst case
Stack: 0 location
|
This is the 2nd test, with LCD.c included:
Code: |
#include <18F65J90.h>
#fuses HS, NOWDT
#use delay(clock=20000000)
#include <lcd.c>
//================================
void main()
{
while(1);
}
CCS PCH C Compiler, Version 4.069, xxxxx 08-Sep-08 14:30
Filename: 18F65J10.lst
ROM used: 30 bytes (0%)
Largest free fragment is 32730
RAM used: 5 (0%) at main() level
5 (0%) worst case
Stack: 0 locations |
|
|
|
zhzhou Guest
|
|
Posted: Tue Sep 09, 2008 2:53 pm |
|
|
I've discovered that it is the "#org" directive that causes it. Is there a way around this?
Code: | #org LOADER_REAL_START, LOADER_END auto=0 default
#use delay(clock=32000000)
#include "fat32.c"
void main ()
{
} |
|
|
|
|