[ROOT] exceptions, threads and redhat 7

From: Colin Bernet (bernet@kph.uni-mainz.de)
Date: Mon May 14 2001 - 16:50:08 MEST


Hi rooters,

I'm still trying to compile a program (working on redhat 6.1) on redhat
7.0. The attached program is the example of thread using you can find at

http://www-linux.gsi.de/~go4/HOWTOthreads/howtothreads.html#tth_sEc8.3
I shows the 2 unrelated problems I encounter.

-The first one looks to be related to the fact that the compiler (gcc
version 2.96) doesn't accept anymore the following trick :
     mTh= new TThread("memberfunction",
                      (void(*) (void *))&Thread0,
                      (void*) this);

on RH6.1, I just get a warning message like:
Myclass.cxx:98: warning: converting from `void (Myclass::*)(void *)' to
`void *' )

on RH7.0, this is unfortunately an error :

TThreadframe.cxx: In method
`Int_t TThreadframe::Threadstart ()': TThreadframe.cxx:129: ISO C++
forbids taking the address of a non-static member function to form a
pointer to
member
function.  Say `&TThreadframe::Thread0'

To check that, just untar the attached example, and type make.

- the second problem is the "different exceptions" stuff I was talking
about in a previous email :
As it occurs while compiling another module, you have to modify the
Makefile.
replace the line :
TMhs3run.$(ObjSuf): TMhs3run.cxx libTMhs3.so libTThreadframe.so
by :
TMhs3run.$(ObjSuf): TMhs3run.cxx libTMhs3.so
and make.

TMhs3run.cxx cannot be compiled because :
g++ -g -Wall -ansi -frtti -fexceptions -DR__THREAD -D_THREADLIB_ -fPIC
-I/usr/l ocal/root/include -c
TMhs3run.cxx In file included from /usr/include/math.h:64,
                 from /usr/local/root/include/G__ci.h:268,
                 from /usr/local/root/include/TSystem.h:31,
                 from /usr/local/root/include/TThread.h:38,
                 from TThreadframe.h:32,
                 from TMhs3.h:2,
                 from TMhs3run.cxx:11: /usr/include/bits/mathcalls.h:54:

declaration of `double acos (double) throw ()' throws different
exceptions
/usr/local/root/include/TMath.h:306: than previous declaration `double
acos (double)' /usr/include/bits/mathcalls.h:56: declaration of `double
asin (double) throw ()' throws different exceptions
/usr/local/root/include/TMath.h:305: than previous declaration `double
asin (double)' /usr/include/bits/mathcalls.h:58: declaration of `double
...

In TMath.h, we have the following lines :

#if defined(R__AIX) || defined(R__MAC) || defined(R__SOLARIS_CC50) || \
    defined(R__USESTHROW)
// math functions are defined inline so we have to include them here
#include <math.h>
#else // don't want to include complete <math.h>
extern "C" {
   extern double sin(double);
   extern double cos(double);
   extern double tan(double);
   extern double sinh(double);
   extern double cosh(double);
   extern double tanh(double);
   extern double asin(double);
   extern double acos(double);
   extern double atan(double);
   extern double atan2(double, double);
   extern double sqrt(double);
   extern double exp(double);
   extern double pow(double, double);
   extern double log(double);
   extern double log10(double);
}
#endif

The problem comes from the extern declarations. If I replace them by
#include <math.h> the "different exceptions" errors disappear. So
the variable R__USESTHROW is not defined, but should be. I can be done
in the Makefile, but I think it would be better if exceptions work by
default.

cheers,

Colin



--
Colin Bernet
Tel. +49-6131/39-23192
Fax  +49-6131/39-22964







This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:45 MET