Macros

ziggy on 2003-12-12T15:49:28

bbum has some very positive things to say about C99's support for variadic macros.

C's macro system still sucks, but at least now it sucks a whole lot less. :-)


VC++; nested functions

mary.poppins on 2003-12-17T10:01:29

At my job I mostly write C++ code that has to compile under gcc and Macrosoft VC++. I usually develop on unix and port to windows before committing a particular change. A couple months ago, I wrote a bunch of code using the variadic macro gcc extension. Upon trying to port to the version of VC++ used by my employer, I discovered that VC++ didn't support the C99 variadic macros, nor did it have a variadic macro extension. So I had to go through my code and change every use of my macro from FOO(...) to FOO1(a) or FOO2(a,b) etc..

In any case -- have you seen the C nested function feature of gcc? It gives you as much of a closure as is realistically possible without automatic memory management. So using functions like Apache's ap_table_do is much more convenient now. Of course, not as convenient as Perl (dynamic typing, real closures) or ML (type inference, real closures -- including partial application), but still, way better than making a function object class and passing a function object to one of STL's iteration algorithm functions.

For STL, I guess you really have to use the Boost Lambda Library to get your brain-damaged ML. But BLL just feels like a kind of parody. Check out this warning about some compilers not supporting more than 17 nested template instantiations.