#ifdef considered harmful (was: DData)
Keith.Wansbrough at cl.cam.ac.uk
Fri Apr 16 15:29:09 EDT 2004
> Is this a problem? The very big problem with the preprocessor approach is, in
> my opinion, that it's awkward to add a new platform. With Robert's approach
> you just add some new files and don't touch the existing code. With the
> preprocessor approach you need write access to the source code of the library
> in question, I'd say.
Which do you add more often, a new platform or a new function?
Robert's approach makes the first easy and the second hard; the
preprocessor makes the second easy and (you claim) the first hard.
The right choice is clear, then: if you add new functions to your API
more often than new platforms, use the preprocessor; if you add new
platforms more often than new functions, use Robert's approach.
In any case, I think thatwith well-designed macros, preprocessing
allows new platforms to be handled in a localised and easy way in most
More information about the Libraries