Re: Macro redefinition
- From: Ian Collins <ian-news@xxxxxxxxxxx>
- Date: Sat, 01 Sep 2007 08:06:05 +1200
Tor Rustad wrote:
I'm implementing a parser, where there is a lot of different dataWith the require #unded as explained else thread, it is quite common.
elements defined. Now instead of hand-coding X defines, and the massive
number of lines needed for table initialization, I decided to generate
this source instead.
So, I basically used this trick:
void gen_source_function(FILE *out)
{
#define EXPAND_DEF(num, name) generate_source_1(out, num, #name)
#include "iso8583_defs"
#define EXPAND_DEF(num, name) generate_source_2(out, num, #name)
#include "iso8583_defs"
}
where the "iso8583_defs" file, did contain a lot of lines like this:
EXPAND_DEF(1, FIELD_NAME);
EXPAND_DEF(2, ANOTHER_FIELD_NAME);
My question is simply, is the above C code allowed?
One project I worked on used it extensively, but with hind site, we
found the code hard to maintain, so we dropped the technique and used
code generation from XML instead.
--
Ian Collins.
.
- References:
- Macro redefinition
- From: Tor Rustad
- Macro redefinition
- Prev by Date: Re: pointer conversion
- Next by Date: Re: size_t problems
- Previous by thread: Re: Macro redefinition
- Next by thread: Exception in C
- Index(es):
Relevant Pages
|