lib_dsp macro expansion warning

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
User avatar
CousinItt
Respected Member
Posts: 360
Joined: Wed May 31, 2017 6:55 pm

lib_dsp macro expansion warning

Post by CousinItt »

Hi all,

dsp_format.h should allow us to define parameterised macros so that it's easy to change the Q format. I've tried to use the following, but I get warnings everywhere they are used, as below. Any ideas how to fix the code or suppress this particular warning?
.../headers/testdata.h:512: warning: Replacement text "Q0(24)" of macro "Q" involved subsequent text
QF(0.0285019613802433),
from ../src/anc.xc: 35: #include "testdata.h"
macro "QF" defined as: #define QF Q(Q_SIZE) /* .../headers/anc.h:34 */
macro "Q" defined as: #define Q(N) Q0(N) /* ...lib_dsp/api/dsp_qformat.h:21 */
macro "Q_SIZE" defined as: #define Q_SIZE 24 /* .../headers/anc.h:33 */
macro "Q0" defined as: #define Q0(N) Q ## N /* ...lib_dsp/api/dsp_qformat.h:20 */
macro "Q24" defined as: #define Q24(f) (int)((signed long long)((f) * ((unsigned long long)1 << (24+20)) + (1<<19)) >> 20) /* ...lib_dsp/api/dsp_qformat.h:32
Thanks.


User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post by infiniteimprobability »

Hmm the C pre-processor... an interesting beast sometimes.

I tried this and the warning is just that - the parameterised Q macro gives the right result. I don't quite understand why nested substitutions should be an issue here and generate a warning. It is probably related to the ## concatenation token.

Let me phone a friend..
User avatar
CousinItt
Respected Member
Posts: 360
Joined: Wed May 31, 2017 6:55 pm

Post by CousinItt »

Thanks for your comments. I agree it's just a warning, but it's an annoying distraction when you get hundreds of them and there doesn't appear to be any sufficiently surgical option to suppress them. I hope your friend has some suggestions.
Post Reply