| View previous topic :: View next topic |
| Author |
Message |
TheSamuraiElephant
Joined: 04 Aug 2005 Posts: 17
|
Posted: Wed Sep 14, 2005 2:22 am Post subject: struct definition: "Undeclared..." |
|
|
I'm trying to tidy up my code by making structures for some parts but when I try to compile this (this code resides in my main function) cygwin gives me an error:
| Code: | //create structure for holding chunk data
struct Chunk
{
unsigned short ID; //first two bytes
unsigned int size; //last four bytes
};
Chunk firstChunk;
int bytes_read = 1;
bytes_read = sceIoRead(fdin, &firstChunk.ID, sizeof(firstChunk.ID)); |
here's the error cygwin gives: 'Chunk' undeclared (first use in this function)
I don't think it's recognising the struct for some reason...is it something to do with some compiler options? I've searched google but couldn't find anything.
Cheers |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Wed Sep 14, 2005 2:33 am Post subject: Re: struct definition: "Undeclared..." |
|
|
| Try to learn some more C basics and then write "struct Chunk firstChunk". |
|
| Back to top |
|
 |
CyberBill
Joined: 26 Jul 2005 Posts: 86 Location: Redmond, WA
|
Posted: Wed Sep 14, 2005 4:01 am Post subject: |
|
|
You are probably more of a C++ programmer. In C++ you dont need the "struct" in front of it, but in C you do.
Heres a much better workaround that is typically found in most C code:
| Code: |
typdef struct _Chunk
{
unsigned short ID; //first two bytes
unsigned int size; //last four bytes
} Chunk;
Chunk firstChunk;
|
This will make typing "Chunk" just like typing: struct _Chunk. Actually, I think you can get away with taking out the _Chunk part, but I cant be sure unless I try it.
Cheers! |
|
| Back to top |
|
 |
TheSamuraiElephant
Joined: 04 Aug 2005 Posts: 17
|
Posted: Wed Sep 14, 2005 4:43 am Post subject: |
|
|
thanks for the replies, it's working fine now. Actually my main problem was having to notice a variable whos name was typed out with the wrong case (should have had a capital). Stupid mistake I guess.
Thanks again :) |
|
| Back to top |
|
 |
|