| Home | Libraries | People | FAQ | More

## Visual C++ gotchas in VMD

I have discussed throughout the documentation areas of VMD which need to be considered when using Microsoft's Visual C++ compilers with its default preprocessor. The VMD library supports VC++ versions 8 through the latest 14.2. These correspond to Visual Studio 2005 through the current Visual Studio 2019.

I will give here fairly briefly the VC++ quirks which should be taken into account when using VMD. These quirks exist because the VC++ compiler does not have a C++ standard conforming preprocessor with its default preprocessor. More specifically the VC++ compiler does not follow all of the rules correctly for expanding a macro when a macro is invoked. Here is a list for things to consider when using VMD with VC++ and its default preprocessor:

- The BOOST_VMD_IS_EMPTY macro will expand erroneously to 1 if the input resolves to a function-like macro name, which when it is called with an empty parameter expands to a tuple.
- The BOOST_VMD_ASSERT macro, and the corresponding individual VMD ASSERT macros for the various data types, do not cause an immediate compiler error, but instead generate invalid C++ if the ASSERT occurs.
- When the BOOST_VMD_ASSERT macro, or one of the corresponding individual VMD ASSERT macros for the various data types, does not generate an error, and the macro in which it is being used does generate some output, it is necessary to use BOOST_PP_CAT to concatenate the empty result of the VMD ASSERT macro with the normally generated output to correctly generate the final expansion of the macro in which the VMD ASSERT occurs.
- When using BOOST_VMD_EMPTY following some non-empty expansion, or when using BOOST_VMD_IDENTITY, the value returned needs to be concatenated using BOOST_PP_CAT with an empty value. You can use BOOST_VMD_IDENTITY_RESULT to accomplish this transparently.
- Avoid using an empty parenthesis to pass no data as a tuple or seq if VC++8 might be used as the compiler.

When using VC++ with its new standard conforming preprocessor, which as of now is not its default preprocessor in Visual Studio 2019, none of these problems manifest themselves.