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
  • 119,891
  • 44
  • 235
  • 294
Pierre Fourgeaud
  • 14,290
  • 1
  • 38
  • 62

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
  • 413,195
  • 112
  • 811
  • 826