[MINC-development] [kteich@nmr.mgh.harvard.edu: [Fsdev] Mac OS X, MNI, and Point]

Steve M. Robbins minc-development@bic.mni.mcgill.ca
Thu, 31 Mar 2005 00:18:59 -0500


On Wed, Mar 16, 2005 at 11:27:04AM -0500, Robert VINCENT wrote:
> Hi,
> 
> I will be releasing MINC 1.4 within a few days, which will hopefully
> provide a solution.  I tried to prefix all typedefs and #defines
> with "VIO_", 

Yay!!!

> but then in each header there is a block that says:
> 
> #ifndef MINC_PLAY_NICE
> typedef VIO_<type> <type>
> #define VIO_<const> <const>
> #endif
> 
> This should be backward compatible, but if you include <volume_io.h> with
> the new magic "MINC_PLAY_NICE" macro defined, you won't get your namespace
> polluted with Point, X, Y, Z, etc.

I think the idea of providing a backwards compatibility mode is a good
one.  However, if I may nitpick, MINC_PLAY_NICE doesn't strike me as
an intuitive name for this mode.  What about something like
VIO_USE_NAMESPACE?

Incidentally, many folks prefer to test that a symbol is set to
"true" rather than just set; i.e. use

    #if !VIO_USE_NAMESPACE
    typedef ...
    #endif

Then the user can compile with -DVIO_USE_NAMESPACE=0
or -DVIO_USE_NAMESPACE=1.  Symbols not defined evaluate to "false",
so the default behaviour is the backwards-compatible mode of
NOT using the VIO namespace.

When you want to switch the out-of-the-box behaviour, you
could put

    #ifndef VIO_USE_NAMESPACE
    #define VIO_USE_NAMESPACE 1
    #endif

into volume_io.h while still allowing the programmer to
explicitly choose the mode.


Regards,
-Steve