Re: Declarations cause "Error: Non-static-const variable in array dimension"

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Thu, 8 Apr 2010 13:55:09 +0200


Hi Stefan,

it's good to point out that people need to understand the basics of C++ to be able to use it (and thus ROOT), but I think it's essential to continue with the tradition of helping even with basic C++ questions. Nobody should be scared to ask well defined questions, the kind of questions that Ida asks. You, Stefan, on the other hand, are very welcome help us out with answering just the more complex questions ;-)

Cheers, Axel.

Stefan Piperov wrote on 04/08/2010 01:41 PM:

> 
> Ida, that's basic C++, not ROOT specific issue.
> Do you really want to bother this list with it?!
> S>
> 
> On Thu, 8 Apr 2010, Ida Häggström wrote:
> 

>> Hi!
>> I'm writing a C-macro to run in ROOT, but I get an error when running it:
>> ----------------------------------
>> Error: Non-static-const variable in array dimension
>> /home/ida/GATE/ROOT_v5.24/root/share/root/macros/Gate_To_Stir_Delayed_modified.C:42:
>>
>> (cint allows this only in interactive command and special form macro
>> which
>> is special extension. It is not allowed in source code. Please ignore
>> subsequent errors.)
>> ----------------------------------
>> The relevant part of my code looks like:
>> -----------------------------------
>> int nRings = 18; // Number of rings in the GE Advance
>> scanner
>> int Num_sinos = nRings*nRings;
>> int nPHI = 336; // Number of angular bins in the
>> sinogram
>> int nU = 283; // Number of radial bins in the sinogram
>> float tmp0[Num_sinos*nPHI*nU], sinogram_STIR_out[Num_sinos][nPHI][nU];
>> -----------------------------------
>> The line which causes the error is the last line, "float tmp0...". I
>> tried
>> changing to "static int" on all int declarations, but the same error
>> appears
>> anyway. Does anyone know what is the problem? Thanks in advance!
>> Ida
>>
> 
> *---------------------------------------------------------------------*
>  Stefan Piperov      Mail: FNAL P.O.Box 500, MS 205, Batavia, IL-60510
>  Phone: (630) 840-5176                        E-Mail: piperov_at_fnal.gov
> *---------------------------------------------------------------------*
> "Give a skeptic an inch... and he'll measure it."
> 
Received on Thu Apr 08 2010 - 13:55:08 CEST

This archive was generated by hypermail 2.2.0 : Thu Apr 08 2010 - 17:50:02 CEST