Reputation: 30404
Is there a macro which checks if an expression is a lvalue
(meaning I can do &expression
) using the C preprocessor?
Example: If there is some int a;
and I call IS_LVALUE(a)
it should evaluate to 1, while IS_LVALUE(5)
should evaluate to 0, so I can do #if IS_LVALUE(...) == 1
Upvotes: 2
Views: 320
Reputation: 63124
No.
Because the C preprocessor has no clue what an lvalue is, or any other C construct for that matter. That's the compiler's job.
Were you in C++ you could use a type trait, but in C I'm afraid you're out of luck.
Upvotes: 11