C dynamic array initialization problem -


i'm having problem initializing array of structs in c program. here's function gets initialized:

void initializebpstructures() {     satcountertable = (struct satcountertableentry *)malloc(sizeof(struct satcountertableentry) * counter_count); } 

counter_count integer global variable , satcountertable declared earlier in c source file

static struct satcountertableentry* satcountertable; 

and if it's relevant satcountertable struct

struct satcountertableentry {     enum satcounter_state predict_state;     md_addr_t tag; }; 

md_addr_t label unsigned int corresponding memory address

the problem when try , compile, following error

sim-safe.c:129: error: expected expression before ‘=’ token 

and array initialization in intitializebpstructures() on line 129. i'm not sure why line problem. ideas?

edit:

here's additional lines of code around function

    struct satcountertableentry {     enum satcounter_state predict_state;     md_addr_t tag; };  /* simulated registers */ static struct regs_t regs;  /* simulated memory */ static struct mem_t *mem = null;  /* track number of refs */ static counter_t sim_num_refs = 0;  /* maximum number of inst's execute */ static unsigned int max_insts;  static struct satcountertableentry* satcountertable;  void initializebpstructures() {     satcountertable = (struct satcountertableentry *)malloc(sizeof(struct satcountertableentry) * counter_count); }  void branchpredict(md_addr_t pc, md_addr_t nextpc, enum branch_result result) {     if (result == n)         sim_num_mispred_static++;     if (result != (myrand() % 2))         sim_num_mispred_random++;          sim_num_br++;  } 

you're missing semicolon @ line 126.


edit: new idea

do perhaps have #define =?

#define counter_count = 42; /* wrong */ #define counter_count = 42  /* wrong */ #define counter_count 42;   /* wrong, works time */ #define counter_count 42    /* correct */ 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -