Visual Studio won't be able to compile MACRO function with local variable?

Hi, geeks:

It seems Visual Studio is not able to build the following MACRO with a new local variable
__x
allocated.

1
2
3
4
#define FAST_SCALE_PQ(X,P,Q) ({						\
   unsigned __x = (X);							\
   func1( __x * (P), __x, __x, (Q) );				\
}) 


GCC seems to work fine. I also tested
1
2
#define TEST_FAST_SCALE_PQ(X,P,Q)   \
    func( ( (X) * (P) ), (X), (X), (Q) ); 

still wrong.

Any work around?

Thank you very much.


Best Regards
Pei
Last edited on
Macros aren't built, they are just literally replaced with their right hand side during the preprocessing stage. What exactly is your problem with Visual Studio (what version of VS anyways?), meaning, what exactly doesn't work?
I think this surrounding the macro in parathesis is a GCC compiler extension - Statements and Declarations in Expressions - See here

http://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
Topic archived. No new replies allowed.