Is it possible to define a global variable size after the “main” function was started.
Its out of any loop, so it would be executed only one time on bootup.
try_time = 11;
snmp_trap(lan.IP_SNMP, SNMP_TRAPDEST , 64, 0, trapindices);
snmp_trap(lan.IP_SNMP2, SNMP_TRAPDEST, 64, 0, trapindices);
“variable definition” int numbers[num_times];
Dynamic C includes a malloc() function that allocates “far” memory, so you could do something like:
int far *numbers;
numbers = malloc(num_times * sizeof(int));
And then later in your code:
foo = numbers;
The problem I’m having is with the ammount of memory left. As I understand, “malloc” reservers the memory beforehand, an I right?
malloc() acquires memory at run-time. But you could just have a compile-time option for maximum number of array entries. An “int” is only 2 bytes – how many were you thinking of storing? Just have “far int numbers[MAX_NUMBERS];” as a global and then decide what to do in your program if num_times somehow ends up larger than MAX_NUMBERS. With embedded, it’s usually easier to allocate all of your memory at compile-time so you know that you have enough room for everything.
Its not too big.
The problem is with total amount of space, however, it’s a separete issue xD
I’d use the size of the array for some function limitations.
You’ve solved the doubt i had, thank you.