Error: Too many initializers, exceeded length of array


I have a standalone application that draws a few canvases, and during initialization I execute (via gSystem->ProcessLine(".x .rootstart.C") ) the following lines as part of a stylesheet in order to set the palette:

const Int_t NRGBs = 5;
const Int_t NCont = 255;

Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);

Every now and then, I get the following error message:
Error: Too many initializers, exceeded length of array for ‘stops’ .rootstart.C:48:
*** Interpreter error recovered ***

By every now and then, I mean maybe once every 3-4 times I execute the program. I’m utterly baffled as to why it only complains sometimes! I should also note I call the exact same stylesheet from my .rootrc and have never seen the error.

Any ideas? I’m using root 5.28/00g and gcc 4.1.2.

Many thanks,

I tried the code you sent in an interpreted macro and in compiled code using the latest ROOT version on Mac and I do not see the problem you are describing here.
Can you reproduce it with a small macro we could run with the ROOT interpreter ?

Hmm. I’m also unable to reproduce with the interactive environement. I also can’t reproduce it with a trivial standalone executable.

If I can manage to reproduce it with something less than the entire enormous project that it’s in now I’ll post it; otherwise I guess there’s not much else that can be done at the moment.

Thanks for looking!

I introduced your code in a standalone program (stressGraphics in $ROOTSYS/test) … but I did not see the problem.

I just found this post as I had the same error message coming up, … and I found a solution so thought I’d post it for anyone else with the same problem.

I was defining a palette in a compiled macro to draw my histogram. This palette had 5 stops. However, I had forgotten that I already defined a palette in my rootlogon.C with only 4 stops.

Commenting out the one in rootlogon.C (and restarting my terminal window) fixed the problem.