Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Don't understand "#define for if-statement" [duplicate]

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.

like image 686
Pierre Fourgeaud Avatar asked Oct 07 '14 14:10

Pierre Fourgeaud


1 Answers

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).

like image 65
aioobe Avatar answered Sep 18 '22 01:09

aioobe