Clang-cl disable exceptions/rtti and macro issue

Hi guys,

I have a couple of problems while trying to compile my program using Clang-cl. First issue, even passing /GR- and Xclang -fno-rtti I get:

                         ^
error: cannot mangle RTTI descriptors for type 'bad_cast' yet
error: cannot mangle the name of type 'bad_cast' into RTTI descriptors yet
error: cannot mangle RTTI descriptors for type 'exception' yet
error: cannot mangle the name of type 'exception' into RTTI descriptors yet
error: cannot mangle RTTI descriptors for type 'bad_cast' yet
error: cannot mangle the name of type 'bad_cast' into RTTI descriptors yet
error: cannot mangle RTTI descriptors for type 'exception' yet
error: cannot mangle the name of type 'exception' into RTTI descriptors yet
error: cannot mangle RTTI descriptors for type 'bad_cast' yet
error: cannot mangle the name of type 'bad_cast' into RTTI descriptors yet
error: cannot mangle RTTI descriptors for type 'exception' yet
error: cannot mangle the name of type 'exception' into RTTI descriptors yet
error: cannot mangle RTTI descriptors for type 'bad_cast' yet
error: cannot mangle the name of type 'bad_cast' into RTTI descriptors yet
error: cannot mangle RTTI descriptors for type 'exception' yet
error: cannot mangle the name of type 'exception' into RTTI descriptors yet
error: cannot mangle RTTI descriptors for type 'bad_cast' yet
error: cannot mangle the name of type 'bad_cast' into RTTI descriptors yet
error: cannot mangle RTTI descriptors for type 'exception' yet
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 warnings and 20 errors generated.

And I can't find a switch for disabling exceptions.

Second problem (I think I've encountered this before and fixed it with -fno-delayed-template-parsing, however it doesn't seem to work on clang-cl or the argument has since been removed from clang)

In file included from I:\boost_1_55_0\boost/filesystem.hpp:16:
In file included from I:\boost_1_55_0\boost/filesystem/path.hpp:25:
In file included from I:\boost_1_55_0\boost/filesystem/path_traits.hpp:22:
In file included from I:\boost_1_55_0\boost/type_traits/decay.hpp:18:
In file included from I:\boost_1_55_0\boost/mpl/eval_if.hpp:17:
I:\boost_1_55_0\boost/mpl/if.hpp(131,1) : error: pasting formed 'BOOST_PP_TUPLE_ELEM_E_2(', an invalid preprocessing token [-Winvalid-token-paste]
BOOST_MPL_AUX_NA_SPEC(3, if_)
^
I:\boost_1_55_0\boost/mpl/aux_/na_spec.hpp(161,40) : note: expanded from macro 'BOOST_MPL_AUX_NA_SPEC'
#define BOOST_MPL_AUX_NA_SPEC(i, name) \
                                        ^
I:\boost_1_55_0\boost/mpl/aux_/na_spec.hpp(154,47) : note: expanded from macro '\
BOOST_MPL_AUX_NA_SPEC_NO_ETI'
#define BOOST_MPL_AUX_NA_SPEC_NO_ETI(i, name) \
                                               ^
I:\boost_1_55_0\boost/mpl/aux_/na_spec.hpp(65,9) : note: expanded from macro '\
BOOST_MPL_AUX_NA_SPEC_MAIN'
         BOOST_MPL_PP_NESTED_DEF_PARAMS_TAIL(i, typename T, na) \
         ^
note: (skipping 5 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
I:\boost_1_55_0\boost/preprocessor/tuple/elem.hpp(36,114) : note: expanded from macro 'BOOST_PP_TUPLE_ELEM'
# define BOOST_PP_TUPLE_ELEM(size, n, tuple) BOOST_PP_TUPLE_ELEM_I(BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM_, n), BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM_E_, size), tuple))
^
I:\boost_1_55_0\boost/preprocessor/cat.hpp(22,32) : note: expanded from macro 'BOOST_PP_CAT'
# define BOOST_PP_CAT(a, b) BOOST_PP_CAT_I(a, b)
                                ^
I:\boost_1_55_0\boost/preprocessor/cat.hpp(31,55) : note: expanded from macro 'BOOST_PP_CAT_I'
# define BOOST_PP_CAT_I(a, b) BOOST_PP_CAT_II(~, a ## b)
                                                       ^
In file included from C:\Scripta\libs\Root\ScriptaConfig.cpp:1:
In file included from C:\Scripta\libs\Root/ScriptaConfig.h:2:
In file included from C:\Scripta\libs\Root/ScriptaLogManager.h:38:
In file included from C:\Scripta\libs\Root/Utility.h:4:
In file included from I:\boost_1_55_0\boost/filesystem.hpp:16:
In file included from I:\boost_1_55_0\boost/filesystem/path.hpp:25:
In file included from I:\boost_1_55_0\boost/filesystem/path_traits.hpp:22:
In file included from I:\boost_1_55_0\boost/type_traits/decay.hpp:18:
In file included from I:\boost_1_55_0\boost/mpl/eval_if.hpp:17:
I:\boost_1_55_0\boost/mpl/if.hpp(131,1) : error: pasting formed 'BOOST_PP_TUPLE_ELEM_1(', an invalid preprocessing token [-Winvalid-token-paste]
I:\boost_1_55_0\boost/mpl/aux_/na_spec.hpp(161,40) : note: expanded from macro 'BOOST_MPL_AUX_NA_SPEC'
#define BOOST_MPL_AUX_NA_SPEC(i, name) \
                                        ^
I:\boost_1_55_0\boost/mpl/aux_/na_spec.hpp(154,47) : note: expanded from macro '\
BOOST_MPL_AUX_NA_SPEC_NO_ETI'
#define BOOST_MPL_AUX_NA_SPEC_NO_ETI(i, name) \
                                               ^
I:\boost_1_55_0\boost/mpl/aux_/na_spec.hpp(65,9) : note: expanded from macro '\
BOOST_MPL_AUX_NA_SPEC_MAIN'
         BOOST_MPL_PP_NESTED_DEF_PARAMS_TAIL(i, typename T, na) \
         ^
note: (skipping 5 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
I:\boost_1_55_0\boost/preprocessor/tuple/elem.hpp(36,53) : note: expanded from macro 'BOOST_PP_TUPLE_ELEM'
# define BOOST_PP_TUPLE_ELEM(size, n, tuple) BOOST_PP_TUPLE_ELEM_I(BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM_, n), BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM_E_, size), tuple))
                                                     ^
I:\boost_1_55_0\boost/preprocessor/tuple/elem.hpp(37,48) : note: expanded from macro 'BOOST_PP_TUPLE_ELEM_I'
# define BOOST_PP_TUPLE_ELEM_I(m, args) BOOST_PP_TUPLE_ELEM_II(m, args)
                                                ^
I:\boost_1_55_0\boost/preprocessor/tuple/elem.hpp(38,64) : note: expanded from macro 'BOOST_PP_TUPLE_ELEM_II'
# define BOOST_PP_TUPLE_ELEM_II(m, args) BOOST_PP_CAT(m ## args,)
                                                                ^
In file included from C:\Scripta\libs\Root\ScriptaConfig.cpp:1:
In file included from C:\Scripta\libs\Root/ScriptaConfig.h:2:
In file included from C:\Scripta\libs\Root/ScriptaLogManager.h:38:
In file included from C:\Scripta\libs\Root/Utility.h:4:
In file included from I:\boost_1_55_0\boost/filesystem.hpp:16:
In file included from I:\boost_1_55_0\boost/filesystem/path.hpp:25:
In file included from I:\boost_1_55_0\boost/filesystem/path_traits.hpp:22:
In file included from I:\boost_1_55_0\boost/type_traits/decay.hpp:18:
In file included from I:\boost_1_55_0\boost/mpl/eval_if.hpp:17:
I:\boost_1_55_0\boost/mpl/if.hpp(131,1) : error: pasting formed 'BOOST_PP_TUPLE_ELEM_E_2(', an invalid preprocessing token [-Winvalid-token-paste]
I:\boost_1_55_0\boost/mpl/aux_/na_spec.hpp(161,40) : note: expanded from macro 'BOOST_MPL_AUX_NA_SPEC'
#define BOOST_MPL_AUX_NA_SPEC(i, name) \
                                        ^
I:\boost_1_55_0\boost/mpl/aux_/na_spec.hpp(154,47) : note: expanded from macro '\
BOOST_MPL_AUX_NA_SPEC_NO_ETI'
#define BOOST_MPL_AUX_NA_SPEC_NO_ETI(i, name) \
                                               ^
I:\boost_1_55_0\boost/mpl/aux_/na_spec.hpp(65,9) : note: expanded from macro '\
BOOST_MPL_AUX_NA_SPEC_MAIN'
         BOOST_MPL_PP_NESTED_DEF_PARAMS_TAIL(i, typename T, na) \
         ^

...and so on...

Thanks a lot for your time.

Clang currently doesn’t support exceptions on Windows. What’s happening is that it’s trying to generate code for them, and failing when attempting to build RTTI data for the catch clauses. We need to improve the diagnostic experience here.

As a workaround, if you aren’t using exceptions in your program, you can pass -D_HAS_EXCEPTIONS=0 to disable use of exceptions in the Visual C++ STL headers. cl doesn’t have a flag to disable exceptions, and so we never added one to clang-cl.