[GiNaC-list] Problem using a user-defined class on Mac OS X.

Chris.Dams at mi.infn.it Chris.Dams at mi.infn.it
Mon Apr 9 15:27:41 CEST 2007


Dear all,

I did some more tests regarding the problem with the fact that
class_info<registered_class>::first occurs more then once in the
executable. I discovered two things.
(1) the problem does not occur when using the static GiNaC library.
(2) I produced a simple test case that exhibits the problem.

// file test.h

#include <iostream>
#include <vector>

template <class T> class test
{   public:
        test()
        {   std::cout << "the address of v is " << (int)&v << std::endl;
        }
        void method() {}
    private:
        static std::vector<T> v;
};

template <class T> std::vector<T> test<T>::v;

extern test<int> t;

// file test.C

#include "test.h"

test<int> t;

// file main.C

#include "test.h"

int main()
{       t.method();
        test<int> t2;
        return 0;
}

// compiling:

$ g++    -c -o test.o test.C
$ g++    -c -o main.o main.C
$ g++ -dynamiclib -o test.dylib test.o
$ g++ -o main main.o -L. -ltest
$ ./main
the address of v is 4563560
the address of v is 343368
$ g++ -o main main.o test.o
$ ./main
the address of v is 343376
the address of v is 343376

I think I will find some gcc or Mac ld forum/newsgroup or whatever to see
if anyone knows about this.

Best wishes,
Chris



More information about the GiNaC-list mailing list