J2Kbr wrote:Released
Gtuner IV 1.08B Revision 2 changelog:- Code: Select all
* Code Editor: File handles are kept closed, so other apps can have write access {GitHub#375}
* GPC Compiler: Implemented garbage collection of unused variables, functions, combos {GitHub#377}
* GPC Compiler: Updated xb1.gph header file to include XB1_SYNC define (BUTTON_21)
Is it possible to discard local variables from discarded functions? Freeing up the static memory.
Example
- Code: Select all
main {
}
void func() {
fix32 a[64];
static fix32 b[64];
return;
}
- Code: Select all
GPC: Variables: Global: 0, Local: 2, Parameters: 0, Pointers: 0, Constants: 0, Labels: 0, Functions: 1, Combos: 0
GPC: Memory usage: Static: 256 bytes (25.00%), Dynamic: 256 bytes (25.00%)
GPC: Second-pass started.
GPC: Unreferenced: func, a, b
GPC: Garbage collection started.
GPC: Discarded: func, a*, b* (* static memory still allocated)
I understand why static variables should be allocated, however, I don't see the purpose of still allocating them from discarded functions. Seeing as they would never be used.
I know by utilizing the preprocessor you can choose to include or to omit the function completely by doing something like this
- Code: Select all
#define func
#include "my_header.gph"
main {
func();
}
my_header.gph - Code: Select all
#pragma once
#ifdef func
#undef func
#define func func
void func() {
fix32 a[64];
static fix32 b[64];
return;
}
#endif
But it would be nice to simply include the header, and not worry about defining any functions that I plan to use.