lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Wim Couwenberg wrote:

Well I remember using () before, I guess {} will work too :)


It will not... The CPP only matches () pairs in macro argument lists

--
Wim


Who speaks about CPP? For example Intel Compiler handles such cases in a sane way.

----------test.c------------------------------
#define TEST(a) do { a; } while(0)
TEST(a = b);
TEST(print(a,b,c) if(a) {b;c;d});
TEST({if(a) {b;c;d;}});
----------------------------------------------

> icl /P test.c

---------test.i-------------------------------
#line 1 "test.c"
do { a = b; } while(0);
do { print(a,b,c) if(a) {b;c;d}; } while(0);
do { {if(a) {b;c;d;}}; } while(0);
----------------------------------------------

`Never use PP a lot', and `never rely on it' are policies, not laws/standarts of programming. In fact there several ways for doing repeated work quickly: default PP of your compiler, your own code generator etc. For example Mike Pall's approach to JIT(as I figured from his earlier msgs) is based on the latter, while GNU lightning's --- on the former.

AMDG,
 Antero Vipunen.