Hello,

It's been ages since i've coded in c and i'm assuming im having a problem with the syntax. I am sure this is stupid and very in my face but i cant seem to work out my errors at compile time.

disk.c: In function `update_rw_requests':
disk.c:531: error: `rw' undeclared (first use in this function)
disk.c:536: error: `algorithm' undeclared (first use in this function)
disk.c: At top level:

Thats the compilers complaints (i have a few more of those from other functions i've written aswell).

528 void update_rw_requests(ReadOrWrite rw, String algorithm)
529 {
530     stats_num_requests++;
531     if (rw == READ) {
532         stats_num_reads++;
533     } else if (rw == WRITE) {
534         stats_num_writes++;
535     } else {
536         fprintf(stderr, "%s: bad rw\n", algorithm);
537     }
538 }

This one is a little more straightforward than the others with the same type of error, so i figured it should be easy to spot here.

Just incase this helps make it clear

typedef enum {
    READ, WRITE
} ReadOrWrite;

Thanks for any and all help guys :)

- xyster

What is 'String' ? What are you sending to this function; can you show how you call it? Because I suspect you want:

void update_rw_requests(ReadOrWrite rw, char* algorithm)

i was calling it with this

update_rw_requests(rw, "cscan");

In that case, just make the change I suggested in my previous post and this problem should be solved!

Thankyou so very much niek_e. Kicks myself for not realising.

You guys are amazingly fast on this site. It's so helpful for frustratingly annoying little things i stuff up :)

Thanks for the help. I will mark the thread as solved and add to your rep :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.