A89: Re: Parse Error


[Prev][Next][Index][Thread]

A89: Re: Parse Error




Hi!

| I just decided to try to write a program for the 89 using TIGCC.. For some
| reason, I get a parse error when I do this:
|
| int Routine(int& p1, int& p2, int& p3)
| {
|  DrawStr(15,75,"Calculator",A_NORMAL);
|  ngetchx();
|  DrawStr(15,75,"Calculator",A_XOR);
|  return 0;
| }

The reason this doesn't work is that C, unlike C++, doesn't support passing
parameters by reference.  Instead, you have to use pointers.  This should
fix it, although I don't see what the parameters actually do:

int Routine(int* p1, int* p2, int* p3)
{
 DrawStr(15,75,"Calculator",A_NORMAL);
 ngetchx();
 DrawStr(15,75,"Calculator",A_XOR);
 return 0;
}

If you called it like this before:

Routine (a, b, c);

you have to do it this way now:

Routine (&a, &b, &c);

This will pass pointers to a, b, and c.  If you use the parameters somewhere
in the function, you have to use *p1 instead of p1 now (to dereference the
pointers).

I hope this helps.  It's kind of surprising that this doesn't even work in
GNU C, but I guess this extension is just not included.  Pascal has this
problem solved, and I think there is a Pascal compiler for TI-89s, called
UltraPascal.  I'm going to look into that sometime, just to see what it can
do.

Bye,
Sebastian




Follow-Ups: References: