www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/12/06:59:48

Message-Id: <2.2.32.19970212161322.006a0a88@mailhost>
Mime-Version: 1.0
Date: Wed, 12 Feb 1997 14:13:22 -0200
To: djgpp AT delorie DOT com
From: Eyal Ben-David <eyalb AT aks DOT com>
Subject: Re: typeinfo.h and math.h conflict

At 07:21 PM 2/11/97 +0200, you wrote:
>
>On Tue, 11 Feb 1997, Matthias Baas wrote:
>
>> g:/lang/cxx/std/stdexcep.h:58: previous declaration of `struct
>> exception & exception::operator =(const struct exception &)' with C++
>> linkage
>> g:/include/math.h:79: conflicts with new declaration with C linkage
>> g:/include/math.h:79: confused by earlier errors, bailing out
>> 
>> So why is there a class named "exception" in math.h and how can I
>> use math.h and exception handling together in my programs?


>Here's the scoop: math.h doesn't declare a class named ``exception'' (of 
>course), it defines a ``struct exception''.  I don't know whether this is 
>just an incompatibility between GCC 2.7.2.1 and libg++ 2.7.1 (anybody?), 
>

In C++ a struct is a class with members default to "public", so the C++
compiler is indeed confused because of the duplicate declarations,
and therefore there is an incompatibility between "struct exception" 
and libg++ 2.7.1.

The draft standard declares "class exception" as a base class for exception
handling classes. 

All the standard C++ types (classes) are in the namespace "std" and the
C++ exception class is "std::exception".

libg++ 2.7.1 does not support (is not built with) namespaces so there
is a name clash.

>but as far as I could see, if you compile your source with -posix, the 
>problem will go away.  (However, I didn't actually try this, so I might 
>be mistaken.)

I think strict ansi will be good also.
 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019