[subexp-daq] NURDLIB - working with arrays of variable length (e. g. for different channel numbers)

Weber, Guenter Dr. g.weber at hi-jena.gsi.de
Tue Apr 23 23:40:55 CEST 2024


Dear friends,


I am having trouble to correctly implement the possibility of various numbers of channels in caen_v7nn.c.


For example in INIT_FAST, I wanted to change


uint16_t threshold_array[32];


to


uint16_t* threshold_array;
threshold_array = calloc(a_v7nn->number_of_channels, sizeof(uint16_t));


However, at some points in the code, the length of the array is determined by something like


sizeof array / sizeof array[0]


and this fails if we just have the pointer.


I found some explanations and possible solutions here: https://stackoverflow.com/questions/37538/how-do-i-determine-the-size-of-my-array-in-c


However, I assume this is much too complicated and I should just try to implement this differently. Maybe this issue came already up for some other module and was solved long time ago.


Could you give me a hint?




Thank you very much!



Best greetings

Günter



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.chalmers.se/pipermail/subexp-daq/attachments/20240423/5b4a8ee7/attachment.html>


More information about the subexp-daq mailing list