These are my two structs:
struct upset {
int location;
int trigger;
int type;
char bits[8];
};
struct event {
int category;
int spill;
int num_clock_ups;
int num_data_ups;
struct upset clock_ups[512];
struct upset data_ups[512];
};
but when i try to declare an array of struct events further down with this:
int nevents = 1755;
struct event total_events[nevents];
i get a segfault the first time i try to access anything in the array, upon checking with gdb, just before the segfault sizeof(total_events) is 0 and the difference in locations of total_events[1] and total_events[2] is 0x10, so it seems the arrays of struct upsets are not getting intialized or something.
what did i do wrong in initializing this array? are my structs set up poorly? i am very new at structs in C and in general.
Is your process stack space big enough? By my calculation that array is going to take up at least (ignoring potential structure member alignment padding):
of space. If
total_eventsis a local variable, it’ll be allocated on the stack. Do you have that much stack space?