2

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

iblue
  • 27,950
  • 18
  • 84
  • 126

1 Answers1

11

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.

Quentin
  • 60,592
  • 7
  • 125
  • 183