[cfe-commits] [patch] Let clang parse typeid() on windows if _HAS_EXCEPTIONS is defined to 0

Nico Weber thakis at chromium.org
Wed Apr 25 15:59:57 PDT 2012


Ping.

On Tue, Apr 24, 2012 at 7:38 PM, Nico Weber <thakis at chromium.org> wrote:
> Hi,
>
> if _HAS_EXCEPTIONS is set to 0, typeid() can't be used in clang on
> windows. One use case where this happens is ICU in chromium:
> http://git.chromium.org/gitweb/?p=chromium/deps/icu46.git;a=commitdiff_plain;h=8ad988882c0a6bb2ac66eecab662141110840e66
>
> This is a reduced reproduction that builds fine with MSVC:
>
> #define _HAS_EXCEPTIONS 0
> #include <exception>
> #include <typeinfo> // for typeid to work.
>
> void f() {
>  (void)typeid(int);  // just typeid
> }
>
> clang on the other hand complains about typeid requiring an include
> for <typeinfo>. That's because clang tries to look up std::type_info,
> and the MS typeinfo header apparently doesn't define type_info in the
> std namespace, but only if _HAS_EXCEPTIONS is defined to 0. The
> attached patch lets clang look up type_info in the global namespace in
> ms compat mode if the lookup for std::type-info fails.
>
> Ok?
>
> Nico




More information about the cfe-commits mailing list