What is the proper way to perform a divide and round to lower number for a macro?
I am trying to do this:
#define TOTAL_NUM_FFTS (int) NO_SAMPLES / FFT_SIZE
but I am getting a warning of incompaitible redefinition of that macro and the compiler restates the line as:
#define TOTAL_NUM_FFTS(int) NO_SAMPLES / FFT_SIZE without the space between TOTAL_NUM_FFTS and (int).
Thanks for your help!
The preprocessor thinks (int) is a parameter to the macro.
When defining macros, use as many parentheses as you can. For example, think what will happen if someone defines FFT_SIZE as 2+3. Instead of dividing by 5, you’d be dividing by 2 and then adding 3.