Is there a way to convince the C preprocessor to evaluate a transcendental function of a constant at compile-time?
For example, replace (int)256*sin(PI/4)
with 181
. This will help me keep magic numbers out of my code.
If it makes a difference, I'm using MSPGCC 4.5.3 and I have no sin()
or cos()
available at runtime.
The C preprocessor can't provide sin() or cos().
For my applications, I use a perl script to create a separate .h file containing the needed precalculations. There are probably sexier ways to do it, but this integrates into my workflow well enough.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With