Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

typeinfo.h with _HAS_EXCEPTIONS = 0 and _STATIC_CPPLIB defined

148 views
Skip to first unread message

tom_usenet

unread,
Apr 21, 2004, 12:01:55 PM4/21/04
to
On Wed, 21 Apr 2004 03:51:03 -0700, "JJ"
<anon...@discussions.microsoft.com> wrote:

>typeinfo.h doesn't compile with _HAS_EXCEPTIONS = 0 and _STATIC_CPPLIB defined. I was able to fix it by replacing _CRTIMP with _CRTIMP2 (together with the appropriate _STATIC_CPPLIB check).

What library and compiler version? What compiler for that matter? Are
you sure that _HAS_EXCEPTIONS = 0 is supported?

Tom
--
C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html

tom_usenet

unread,
Apr 22, 2004, 6:32:05 AM4/22/04
to
On Thu, 22 Apr 2004 00:26:03 -0700, "JJ"
<anon...@discussions.microsoft.com> wrote:

>I'm using the vanilla compiler and standard library headers that come with .NET 2003.
>
>_HAS_EXCEPTIONS = 0 is certainly not documented - I was testing a suggestion in one of this year's GDC presentations (http://www.gdconf.com/archives/2004/isensee_pete.ppt).
>
>_HAS_EXCEPTIONS certainly appears liberally throughout the standard headers, so it *looks* like it's supported.

Dinkumware's library can be made to work with exceptions disabled (via
the macro in question), but I don't think the version of the library
that they ship with .NET has this facility (since disabling exceptions
isn't particularly desirable outside of an embedded environment). If
you want that facility, then you can buy their full library (from
www.dinkumware.com) or use a version that does have that feature
enabled (such as, I suspect, the version that ships with Embedded VC++
(for Windows CE or Xbox)).

tom_usenet

unread,
Apr 23, 2004, 10:11:44 AM4/23/04
to
On Thu, 22 Apr 2004 03:56:06 -0700, "JJ"
<anon...@discussions.microsoft.com> wrote:

>With .NET 2003, my own experience is that it works Just Fine (TM) if you use _HAS_EXCEPTIONS = 0 *without* _STATIC_CPPLIB. It's only in combination with _STATIC_CPPLIB that the problem occurs.

This suggests it wasn't tested. Are you sure it actually *works* with
the DLL lib, as opposed to just compiling. I have a feeling that
::bad_cast is thrown (rather than "raised") rather than std::bad_cast
being "raised".

>The fact that the fix is so easy suggests to me that there is no intention for _HAS_EXCEPTIONS not to work in general with .NET 2003 - it's simply a bug in the headers.

I don't think it is a bug - typeinfo.h is a Microsoft header, and it
doesn't seem to be designed to work with Dinkumware's exception
disabling mechanism.

Certainly the facility to disable exceptions is only documented for
the EC++ library:
http://www.dinkumware.com/manuals/reader.aspx?b=a/&h=lib_cpp.html#Exceptions
The normal unabridged library documentation has no such section.

Still, if you need it and can get it working, good luck to you!

P.J. Plauger

unread,
Apr 23, 2004, 11:51:52 AM4/23/04
to
"tom_usenet" <tom_u...@hotmail.com> wrote in message
news:gd0i809pb6ahi1kkj...@4ax.com...

Actually, disabling exceptions works with all versions of our
C++ library. We left the conditional logic in for VC++ at
Microsoft's request. And we did test it, of course. But
_STATIC_CPPLIB is not one of our macros, so we didn't test
for interactions with _HAS_EXCEPTIONS.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com


tom_usenet

unread,
Apr 23, 2004, 1:33:31 PM4/23/04
to
On Fri, 23 Apr 2004 11:51:52 -0400, "P.J. Plauger"
<p...@dinkumware.com> wrote:

>Actually, disabling exceptions works with all versions of our
>C++ library. We left the conditional logic in for VC++ at
>Microsoft's request. And we did test it, of course. But
>_STATIC_CPPLIB is not one of our macros, so we didn't test
>for interactions with _HAS_EXCEPTIONS.

Where are your configuration macros documented?

P.J. Plauger

unread,
Apr 23, 2004, 5:24:20 PM4/23/04
to
"tom_usenet" <tom_u...@hotmail.com> wrote in message
news:nqki80lde0tio0j7s...@4ax.com...

> On Fri, 23 Apr 2004 11:51:52 -0400, "P.J. Plauger"
> <p...@dinkumware.com> wrote:
>
> >Actually, disabling exceptions works with all versions of our
> >C++ library. We left the conditional logic in for VC++ at
> >Microsoft's request. And we did test it, of course. But
> >_STATIC_CPPLIB is not one of our macros, so we didn't test
> >for interactions with _HAS_EXCEPTIONS.
>
> Where are your configuration macros documented?

We document the ones we leave in for a given package in its
readme.txt. For OEMs we leave it to them to tell the customers
what they choose.

tom_usenet

unread,
Apr 26, 2004, 12:42:25 PM4/26/04
to
On Mon, 26 Apr 2004 04:21:04 -0700, "JJ"
<anon...@discussions.microsoft.com> wrote:

>More info on this - for various historical reasons, we have "using namespace std;" at the top of one of our main headers, and it is only under these circumstances that this issue looks like an interaction between _HAS_EXCEPTIONS and _STATIC_CPPLIB. My bad, I guess - apologies for the bum steer.
>
>In the absence of "using namespace std;", it looks like a straight _HAS_EXCEPTIONS issue. The following code repros the problem:
>
>#define _HAS_EXCEPTIONS 0
>#include <typeinfo>
>
>It still looks like a problem relating to <typeinfo.h> - it attempts to define the class ::bad_cast (: public ::exception) but when _HAS_EXCEPTIONS = 0 the base class ::exception is not defined (as opposed to std::exception, which is).

Does:
#define _HAS_EXCEPTIONS 0
#include <exception>
using std::exception;
#include <typeinfo>

work? Or is that what you're trying to avoid? It looks like the
problem is that Dinkumware don't dump their non-exception
std::exception class into the global namespace (which is where
Microsoft's headers seem to expect it to be).

0 new messages