March 07, 2006
Don Clugston wrote:
> Unfortunately, the preprocessor solution doesn't always work. Some macros must be expanded, some must not be.
> For example, one file I've converted is littered with things like:
> 
> #define DAQmx_Val_Rising                      10280
> 
> It's never referenced elsewhere in the file. So, if you run it through a preprocessor, it just disappears.
> It needs to be converted to:
> const DAQmx_Val_Rising = 10280;
> (Actually this one really should have been an enum).
> 
> Null defines are easy:
> #define ABC
> this always means ABC will only ever be used in a #ifdef statement, so it should never appear in the file. Unfortunately, sometimes you find
> #define ABC 1
> even though the value of ABC is never used.
> It might be possible to do an initial pass through all header files, trying to work out the purpose of each #define.
> It seems to be very easy to deal with the first 95% of cases; probably the last 1% of pathological cases are ten times as difficult as everything else combined.

80-20 is good. 95-5 would be excellent. 99-1 is more than anyone should reasonably ask for. 100-0 is just not worth the effort.

But at 95-5, the remaining 5% may often be quite obvious to the astute human reader, I hope.

Just as long as the 95% is a correct (but not necessarily the same as a human would do) translation, and the remaining 5% is clearly marked.
1 2 3
Next ›   Last »