variable-sized object may not be initialized

0

I'm having an error when I ask the WORLD X and WORLD Y values on the command line

  

error: variable-sized object may not be initialized        AGENT * grid [WORLD_X] [WORLD_Y] = {NULL};

/* Verificar se numero de argumentos foi o correto */
if (argc != 8) {
    fprintf(stderr, "Modo de uso:\n");
    fprintf(stderr, "\t%s -x -y -z -h -Z -H -t \n", argv[0]);
    exit(-1);
}

unsigned int WORLD_X = atoi(argv[1]);
unsigned int WORLD_Y = atoi(argv[2]);
int NHUMANS = atoi(argv[3]);
int NZOMBIES = atoi(argv[4]);
int NHUMANS_PLAY = atoi(argv[5]);
int NZOMBIES_PLAY = atoi(argv[6]);
int TURNS = atoi(argv[7]);

/* An instance of a SHOWWORLD world display. */
SHOWWORLD *sw = NULL;

/* A by-dimensional array of agent pointers, representing agents in a
   grid. In the final project the agent grid or world should be abstracted
   to specific world.c/world.h files, with new/destroy functions 
   All elements in this grid are initialized to NULL, i.e., they don't
   initially point to anything. */
AGENT *grid[WORLD_X][WORLD_Y] = { NULL };

The program's compilation is using the following command -Wall -Wextra -Wpedantic -std = c99 -g on the ubuntu

    
asked by anonymous 06.02.2018 / 01:24

0 answers