not enough memory to compile function abc
"This could be because you do not have enough free RAM (more than 100kb is recommended), but if you have enough RAM it is probably because the function abc is too large to fit in the memory of the calculator. You will need to split into smaller functions to avoid the error.
Another reason could be that you have a #define
with a large body, or a very
large number of global declarations. This shouldn't be a problem for most
programs, but if you think you are in this case, you can try to solve it with #undef
or by creating a precompiled header.
It all depends on what features your program uses. Here is a list of porting issues:
long long
support: GTC does not support them, if you use them you will have to rewrite your code to use two long
s instead. In many cases it's very easy to port.
asm()
vs asm{}
: the assembly syntax is different between GTC and TIGCC. However if you are familiar with a68k you will be able to use GTC's syntax in no time.
float
/double
support: currently, GTC does not support floats. If your program uses floats, then unless you think you can get rid of them (e.g. if you are only using them for sines and cosines, you can use a pre-computed table instead), you're basically stuck and should definitely continue using TIGCC (unless you're willing to go down to the assembly level). Sorry.
Additionally, you may run into these little behaviour differences:
int *f(int *dest,int x) { memcpy(dest,(int[4]){x,x+1,x+2},8); return dest; }is not accepted by GTC because the array constructed is not constant (
x
is not known at compile time). But you can rewrite it to use a temporary array instead:
int *f(int *dest,int x) { int temp[4] = {x,x+1,x+2}; memcpy(dest,temp,8); return dest; }
regparm(2,1)
convention, while TIGCC uses the stkparm
convention. This is only a problem if you have written assembly functions yourself; in this case, you have to specify the calling convention you use in the prototype, e.g.:
asm { upper_8_bits: move.b 4(a7),d0 rts }; char upper_8_bits(long x);would become
asm { upper_8_bits: move.b 4(a7),d0 rts }; char upper_8_bits(long x) __attribute__((stkparm));
This list may not be exhaustive, but I will be happy to hear about any problems you might have that are not mentioned in this list.
You should not have much trouble compiling GTC programs with TIGCC as GTC was designed to introduce as few incompatibilities as possible. However, if you use low-level features like assembly you might run into some problems:
asm { turn_calculator_off: trap #4 rts };into this more portable program:
#ifdef __GTC__ /* assembly code using GTC'sasm{}
syntax */ asm { turn_calculator_off: trap #4 rts }; #else /* assembly code using TIGCC'sasm()
syntax */ asm(" turn_calculator_off: trap #4 rts "); #endif
regparm
.