[ROOT] Problem with <complex> when using compiled library

From: Malcolm Davidson (davidson@cesbio.cnes.fr)
Date: Mon Nov 27 2000 - 10:05:57 MET


Hello,

I'm having trouble using a class definition containing complex numbers
when it is compiled as a shared library using CINT. The definition works
fine in interpreted mode. I've included examples below. For the record I
am using Mandrak Linux 7.2 and ROOT v2.25 which I compiled from sources.

Many thanks in advance for your help.

Malcolm

**************************************************
Interpreted result
**************************************************
root [2] .L /home/davidson/root/macros/test/IEM_TEST.cpp
root [3] IEM iem;
root [4] iem.print_par();
=> Dielectric constant = (3,0.1) // OK
root [5] iem.setEPS(complex<float>(10.0,0.1))
root [6] iem.print_par();
=> Dielectric constant = (10,0.1) // OK

**************************************************
Using compiled library
**************************************************
root [15] .L /home/davidson/root/macros/test/IEM_TEST.cpp+
Creating shared library /home/davidson/root/macros/test/IEM_TEST.so
Note: operator new() masked 1c
Note: operator delete() masked 1c
Class IEM: Streamer() not declared
Class IEM: ShowMembers() not declared

root [16] .x /home/davidson/root/macros/test/TEST.cpp
Warning: File "iostream.h" already loaded
Dielectric constant = (3,0.1) //OK
Dielectric constant = (5.35546,5.35546) //WRONG should be (10,0.1)

Here are the class definition and script
**************************************************
IEM_TEST.cpp
**************************************************
#include <complex>
#include <iostream.h>
class IEM {
 public:
  IEM();
  void setEPS(const complex<float>&);
  void print_par();

private:
    complex<float> eps;
};

IEM::IEM() {
    eps=complex<float>(3.0,0.1);
}
inline void IEM::setEPS(const complex<float>& eps_in) {
  eps=eps_in;
}
void IEM::print_par(){
  cout << "Dielectric constant = " << eps << endl;
}

**************************************************
Calling function
**************************************************

{
gROOT->Reset();

#include<iostream.h>
#include<complex>

IEM iem;
complex<float> eps;

iem.print_par();
iem.setEPS(complex<float>(10.0,0.1));
iem.print_par();
}




<>------------------------------------------------<>
Malcolm W. J. Davidson

Centre D'Etudes Spatiales de la Biosphere (CESBIO)
UMR 5639 CNES-CNRS-UPS
18, Avenue Edouard Belin
F-31401 Toulouse Cedex 4
FRANCE

e-mail : davidson@cesbio.cnes.fr
phone (33)(0)5.61.55.85.84
fax   (33)(0)5.61.55.85.00
<>------------------------------------------------<>



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:38 MET