Re: A89: Re: Please help with C
[Prev][Next][Index][Thread]
Re: A89: Re: Please help with C
Hi!
> Well... You're right. But only partially. ANSI C doesn't allow nested
> functions. BUT as TI-GCC is really a GCC, Gnu C Compiler, it has quite a
lot
> of extensions. One of them is that you CAN define and use nested
functions.
> I know very well that they aren't _really_ needed, at least I haven't
ever
> had the need to use them.
Yes, I know that GNU C allow nested functions :-) But you can't nest them
on the way how Simon does it...
> AFAIK nested functions don't need any special internal functions to work.
So
> they should work with TI-GCC. Yeah, it is better to not to use nested
> functions.
Nested functions may be very useful sometimes...
> Oh, BTW, complex is also a valid data type in GCC... But probably that
needs
> some special internal functions to work.
>
> So, AFAIR:
>
> __complex__ int c;
> __complex__ int h=1+2i;
> __complex__ char m;
>
> is valid in GCC.
>
> Then you can access it's real and imaginary parts like:
>
> r=__real__ c;
> i=__imag__ c;
For "complex integers" you don't need any special functions afaik.
But, you can't use "complex float" using this method, because such
"complex floats" will not be compatible with TIOS.
> Oh, then, as you know, GCC allows also embedding of assembler statements
in
> C source. I.e. in-line assembler. I'm not sure if Zeljko's TI-GCClib uses
> them, but for others too:
>
> int phew(int i, int j)
> {
> asm ("addw %1,%0;"
> : "=d" (j) /* output goes into j */
> : "d" (i), "d" (j) /* inputs are in i and j */
> );
> return j;
> }
> Well, that's very cryptic. But what that _should_ do is to add i to j.
The
> compiler handles moving i and j to registers... And those %0 and %1 mean
> that compiler is allowed to decide registers it likes most. Hmm, well.
> That's very damn cryptic to explain. Especially when you're not so sure
> yourself. I'll try to find some tutorial sometime, if anybody is
> interested. But more about in-line assembler is said in GCC infopage.
Refer
> to that for all GCC's extensions.
Of course, I used such possibilities on few places in TIGCCLIB :-)
This is very very useful... but just more cryptic...
Zeljko Juric