Hello.
I have tried to use dynamic array of my structure but it doesn’t work.
I fill it in CINT and then immediately read it in compiled code but it’s corrupted.
my_structures.h
struct TestStructure
{
unsigned int serial;
int channel;
int pedestal;
int noise;
int test;
};
Filling in CINT macro test.C:
[code]#include "my_structures.h"
void test()
{
gSystem->Load(“libTest”);
int element_count = 4;
TestStructure* test_struct = new TestStructure[element_count];
for (int i = 0; i < element_count; i++)
{
test_struct[i].serial = i;
test_struct[i].channel = i;
test_struct[i].pedestal = i;
test_struct[i].noise = i;
test_struct[i].test = i;
}
test_func(test_struct, element_count);
}[/code]
Reading in test.cxx of the libTest library:
[code]#include "my_structures.h"
test_func(TestStructure* parameter_value, int element_count)
{
for (int i = 0; i < element_count; i++)
{
cout<<“Element “<<i<<”:”<<endl;
cout<<"serial = “<<parameter_value[i].serial<<”; "<<"channel = “<<parameter_value[i].channel<<”; "<<"pedestal = “<<parameter_value[i].pedestal<<”; "<<"noise = “<<parameter_value[i].noise<<”; "<<"test = "<<parameter_value[i].test<<endl<<endl;
}
return;
}[/code]
But it prints corrupted values:
[quote]Element 0:
serial = 0; channel = 0; pedestal = 0; noise = 0; test = 0
Element 1:
serial = 0; channel = 1; pedestal = 1; noise = 1; test = 1
Element 2:
serial = 1; channel = 1714386032; pedestal = 2; noise = 2; test = 2
Element 3:
serial = 2; channel = 2; pedestal = 1953460082; noise = 3; test = 3[/quote]
Please, advice me what should I do with it?