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

From: Ida Häggström <ida.haggstrom_at_radfys.umu.se>
Date: Thu, 8 Apr 2010 16:06:59 +0200


Dear Axel and Benjamin,

Thank you both for your valuable input and help! I "solved" the problem by making my C-script a macro, not a function (i.e. removing the first line of the script saying "void Gate...(int fileNumber)"). Now I don't get any error, the script can run in ROOT. I have no idea what the reason is, but I guess it is a C++ question as well. Anyway, I moved around some folders and stuff so I didn't have to pass anything into the script, hence I could remove the function and run everything. Maybe there's still something wrong with the code, but at least it runs now! =)

Thank you for all your time and help anyways! Ida

Den 8 april 2010 13.55 skrev Axel Naumann <Axel.Naumann_at_cern.ch>:

> 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 - 16:07:03 CEST

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