Could it be that the function __builtin_frac is not implemented although it is in the documentation (c.pdf)? I get an error "unknown identifier _builtin_frac used in function call" when trying to do something like
__builtin_frac was supposed to be a builtin keyword to C, but somehow it's missing from the C keywords table. I will fix that in the next release (it's fixed in github now). Thanks for catching this!
In the meantime you can work around this by defining a function like:
unsigned myfrac(unsigned a, unsigned b) {
unsigned r = 0;
__asm {
setq a
qdiv r, b
getqx r
}
return r;
}
which should usually expand to the same code as the builtin, at least on P2 (the builtin will also work in some other environments).
Comments
Could it be that the function
__builtin_frac
is not implemented although it is in the documentation (c.pdf)? I get an error "unknown identifier _builtin_frac used in function call" when trying to do something likeDo I need to #include something else additionally to "propeller2.h" to make it work?
__builtin_frac
was supposed to be a builtin keyword to C, but somehow it's missing from the C keywords table. I will fix that in the next release (it's fixed in github now). Thanks for catching this!In the meantime you can work around this by defining a function like:
which should usually expand to the same code as the builtin, at least on P2 (the builtin will also work in some other environments).