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
  • 29,609
  • 19
  • 89
  • 128

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
  • 62,093
  • 7
  • 131
  • 191