I'm trying to use global variables to store 3 values from a file. When I run my project this is the error I get:
error: variably modified ‘pkt’ at file scope
error: variably modified ‘num’ at file scope
Here is my code:
config.h
#ifndef READCONFIG_CONFIG_H
#define READCONFIG_CONFIG_H
#include <stdio.h>
#define PATH "src/transferConfig.txt"
extern unsigned long int TIMEOUT_PKT;
extern int START_BUFFER_SIZE;
extern float PROBLOSS;
int getConfig(){
FILE *fp;
int n;
float p;
unsigned long int t;
if((fp = fopen(PATH,"rt")) != NULL) {
fscanf(fp, "N=%d\n p=%f\n T=%ld\n", &n, &p, &t);
fclose(fp);
TIMEOUT_PKT = t;
START_BUFFER_SIZE = n;
PROBLOSS = p;
}else{
TIMEOUT_PKT = 3000000;
START_BUFFER_SIZE = 15;
PROBLOSS = 0;
}
}
#endif //READCONFIG_CONFIG_H
window.h
typedef struct window{
packet* pkt[START_BUFFER_SIZE];
long num[START_BUFFER_SIZE];
}window
Error during the build
error: variably modified ‘pkt’ at file scope
error: variably modified ‘num’ at file scope
How can I fix this error?