5

I was looking at a code used to wrapped lua into a C++ application.

I was very surprised to find this:

#define for if (false) {} else for

I don't understand the meaning of this. To me, it seems useless to do something like that.

Does it have to do something with some compiler tricks or something else ?

PS: The library I was looking at is luabind.

Yu Hao
  • 115,525
  • 42
  • 225
  • 281
Pierre Fourgeaud
  • 14,042
  • 1
  • 36
  • 59

1 Answers1

6

I've seen something similar to this to mitigate a compiler bug where the scoped of the for-variable leaked outside of the for-statement.

Related: /Zc:forScope (Force Conformance in for Loop Scope).

aioobe
  • 399,198
  • 105
  • 792
  • 807