[aquaria] Visual Studio naming conflicts

Andrew Church achurch+aquaria at achurch.org
Sun Jul 11 13:36:40 EDT 2010


>I did some checking and it turns out that InputMode, INPUT_MOUSE, and
>INPUT_KEYBOARD in there are all already defined by Visual Studio.  So is
>hash() in Base.h/cpp, as I later found.  After renaming those (along with
>INPUT_JOYSTICK, for consistency), I was able to compile fine, so I wanted to
>submit a patch for this.

Another possibility is to just redefine/undefine those specific macros
when building in Visual Studio -- that would be my suggestion, as it
avoids the need to rewrite identifiers in dozens of different files.
This could probably be done in BBGE/Base.h, with something like:

// Rename anything that's a type or function (not a #define).
#ifdef _MSC_VER
#define InputMode _MSC_InputMode
#define hash _MSC_hash
#endif

// System #includes go here.

// Undefine the renaming macros as well as other macros defined by the
// system headers that we don't want.
#ifdef _MSC_VER
#undef InputMode
#undef INPUT_MOUSE
#undef INPUT_KEYBOARD
#undef hash
#endif

This is the approach I've used in my own cross-platform work, though
usually just to work around identifier shadowing warnings.  (I'd
certainly like to have a few words with whoever on the POSIX committee
thought it would be a good idea to have global library functions named
y0() and y1()...)

  --Andrew Church
    achurch at achurch.org
    http://achurch.org/


More information about the aquaria mailing list