Re: CINT (ROOT v5.30) does not compile class with static const members

From: Neal Gauvin <Neal.Gauvin_at_unige.ch>
Date: Wed, 25 Apr 2012 14:27:04 +0200


Hi,

It works so fine. Thanks.

I also try to compile the initial code with lated ROOT v5.32 and dev version, CINT compilation fails with the same errors as reported.

Cheers,

Neal

Le 25/04/2012 14:09, Benjamin Bannier a écrit :
> Hi,
>
> what Timur meant was that you cannot initialize common_lim in the class
> declaration. There you should only have
>
> static const double common_lim; //!
>
> In the implementation test.C you can then initialize it, outside of any
> function
>
> const double test::common_lim = 100;
>
>
> HTH,
>
> Benjamin
>
>
> On Wed, Apr 25, 2012 at 02:02:45PM +0200, Neal Gauvin wrote:
>> Hi,
>>
>> Thanks for your answer.
>> What you say would work if I had a non const member...
>> But here I have a static const.
>>
>> Cheers,
>>
>> Neal
>>
>>
>> Le 25/04/2012 13:56, Timur Pocheptsov a écrit :
>>> You have to declare static member in .h (remove initializer) and define it in .C file.
>>> ________________________________________
>>> From: owner-roottalk_at_root.cern.ch [owner-roottalk_at_root.cern.ch] on behalf of Neal Gauvin [Neal.Gauvin_at_unige.ch]
>>> Sent: 25 April 2012 13:46
>>> To: roottalk (Mailing list discussing all aspects of the ROOT system.)
>>> Subject: [ROOT] CINT (ROOT v5.30) does not compile class with static const members
>>>
>>> Hi,
>>>
>>> I wrote a class, which contains a static const member.
>>> The class compiles finely with g++, but CINT fails to compile it.
>>>
>>> Info in<TUnixSystem::ACLiC>: creating shared library
>>> /home/gauvin/Polar/europe_svn/trunk/include/./test_C.so
>>> dlopen error: /home/gauvin/Polar/europe_svn/trunk/include/./test_C.so:
>>> undefined symbol: _ZN4test10common_limE
>>> Load Error: Failed to load Dynamic link library
>>> /home/gauvin/Polar/europe_svn/trunk/include/./test_C.so
>>> /usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../lib64/crt1.o: In
>>> function `_start':
>>> (.text+0x20): undefined reference to `main'
>>> /home/gauvin/Polar/europe_svn/trunk/include/test_C_ACLiC_dict.o: In
>>> function `G__setup_memvartest()':
>>> test_C_ACLiC_dict.cxx:(.text+0xde3): undefined reference to
>>> `test::common_lim'
>>> collect2: ld a retourné 1 code d'état d'exécution
>>>
>>> You can find the demo class in attachment.
>>> I am using ROOT version 5.30.
>>> The same code is found to work on ROOT version v5.26
>>>
>>> Does somebody have any Idea what goes wrong ?
>>>
>>> Thanks in advance,
>>>
>>> Neal
>>>
>>> --
>>> _______________________________________________
>>>
>>> Dr. Neal Gauvin
>>> E-mail neal.gauvin_at_a3.epfl.ch
>>> -----------------------------------------------
>>> Data Centre for Astrophysics (ISDC)
>>> Chemin d'Ecogia 16
>>> CH-1290 Versoix
>>> Phone : +41 22 379 2108
>>> _______________________________________________
>>>
>>
>> --
>> _______________________________________________
>>
>> Dr. Neal Gauvin
>> E-mail neal.gauvin_at_a3.epfl.ch
>> -----------------------------------------------
>> Data Centre for Astrophysics (ISDC)
>> Chemin d'Ecogia 16
>> CH-1290 Versoix
>> Phone : +41 22 379 2108
>> _______________________________________________
>>

-- 
_______________________________________________

Dr. Neal Gauvin
E-mail neal.gauvin_at_a3.epfl.ch
-----------------------------------------------
Data Centre for Astrophysics (ISDC)
Chemin d'Ecogia 16
CH-1290 Versoix
Phone : +41 22 379 2108
_______________________________________________
Received on Wed Apr 25 2012 - 14:27:10 CEST

This archive was generated by hypermail 2.2.0 : Wed Apr 25 2012 - 17:50:02 CEST