(no subject)

From: Dmitry Naumov <naumov_at_nusun.jinr.ru>
Date: Fri, 10 Nov 2006 10:59:42 +0300


Dear ROOTers,

I have encountered a strange problem about use of map, vector from root interpreter.
I wrote a simple exercise macro for my students like this:

#include <vector>
#include <map>
#include <iostream>
#include <TString.h>

void test() {

    vector<Int_t> p;
    map<TString,Int_t> m;
    for (Int_t i(0); i<10; i++) {

         p.push_back(i*i);
         TString title = Form("value squared %d",i);
         m[title] = i*i;

    }
    for (UInt_t i(0); i<p.size(); i++) {

         cout << "value " << p[i] << endl;     }
    map<TString,Int_t>::iterator it;
    for (it=m.begin(); it!=m.end(); it++) {

         cout << it->first << " " << it->second << endl;     }
    it = m.find("value squared 4");
    cout << it->first << " " << it->second << endl; }

Then on my laptop I compiled this code as follows: root[].L test.C+
and run it
root[] test()

it gives a correct result and no problem during the compilation. My root version is 5.13/01.
gcc -v output is:
naumov_at_naumov-laptop(10:53)> gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v

--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr 
--enable-shared --with-system-zlib --libexecdir=/usr/lib 
--without-included-gettext --enable-threads=posix --enable-nls 
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu 
--enable-libstdcxx-debug --enable-mpfr --with-tune=i686 
--enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20060928 (prerelease) (Debian 4.1.1-15)

However the same macro is not compiling under other pcs. The following command root[].L test.C+
gives :

Info in <TUnixSystem::ACLiC>: creating shared library
/home/naumov/nuclon//macros/test_vector_C.so
Warning: link requested for unknown srcfile /home/naumov/nuclon
/home/naumov/nuclon//macros/filehmmaiilinkdef.h:10:
Syntax error: #pragma link
/home/naumov/nuclon//macros/filehmmaiilinkdef.h:10:
Warning: Error occurred during reading source files Warning: Error occurred during dictionary source generation !!!Removing /home/naumov/nuclon//macros/filesXPixF.cxx
/home/naumov/nuclon//macros/filesXPixF.h !!!
Error: rootcint: error loading headers... Error in <ACLiC>: Dictionary generation failed! Info in <ACLiC>: Invoking compiler to check macro's validity
/home/naumov/nuclon//macros/test_vector.C: In function ‘void test()’:
/home/naumov/nuclon//macros/test_vector.C:7: error: ‘vector’ was not
declared in this scope
/home/naumov/nuclon//macros/test_vector.C:7: error: expected
primary-expression before ‘>’ token
/home/naumov/nuclon//macros/test_vector.C:7: error: ‘p’ was not
declared in this scope
/home/naumov/nuclon//macros/test_vector.C:8: error: ‘map’ was not
declared in this scope
/home/naumov/nuclon//macros/test_vector.C:8: error: expected
primary-expression before ‘,’ token
/home/naumov/nuclon//macros/test_vector.C:8: error: expected
primary-expression before ‘>’ token
/home/naumov/nuclon//macros/test_vector.C:8: error: ‘m’ was not
declared in this scope
/home/naumov/nuclon//macros/test_vector.C:15: error: ‘cout’ was not
declared in this scope
/home/naumov/nuclon//macros/test_vector.C:15: error: ‘endl’ was not
declared in this scope
/home/naumov/nuclon//macros/test_vector.C:17: error: expected
primary-expression before ‘,’ token
/home/naumov/nuclon//macros/test_vector.C:17: error: expected
primary-expression before ‘>’ token
/home/naumov/nuclon//macros/test_vector.C:17: error: ‘::iterator’
has not been declared
/home/naumov/nuclon//macros/test_vector.C:17: error: expected `;' before
‘it’
/home/naumov/nuclon//macros/test_vector.C:18: error: ‘it’ was not
declared in this scope
/home/naumov/nuclon//macros/test_vector.C:19: error: ‘cout’ was not
declared in this scope
/home/naumov/nuclon//macros/test_vector.C:19: error: ‘endl’ was not
declared in this scope
/home/naumov/nuclon//macros/test_vector.C:23: error: ‘cout’ was not
declared in this scope
/home/naumov/nuclon//macros/test_vector.C:23: error: ‘endl’ was not
declared in this scope

What is strange that the compiler is near the same: naumov_at_nui118(10:57)> gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v

--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr 
--enable-shared --with-system-zlib --libexecdir=/usr/lib 
--without-included-gettext --enable-threads=posix --enable-nls 
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu 
--enable-libstdcxx-debug --enable-mpfr --with-tune=i686 
--enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20060901 (prerelease) (Debian 4.1.1-13)

the root version is older a bit (5.12/00e), but I also checked it with the same root version as mine.

Could anyone shed a light on that? Best regards, Dmitry Received on Fri Nov 10 2006 - 09:00:27 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:01 MET