forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

struct definition: "Undeclared..."

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
TheSamuraiElephant



Joined: 04 Aug 2005
Posts: 17

PostPosted: Wed Sep 14, 2005 2:22 am    Post subject: struct definition: "Undeclared..." Reply with quote

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
View user's profile Send private message
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Wed Sep 14, 2005 2:33 am    Post subject: Re: struct definition: "Undeclared..." Reply with quote

Try to learn some more C basics and then write "struct Chunk firstChunk".
Back to top
View user's profile Send private message
CyberBill



Joined: 26 Jul 2005
Posts: 86
Location: Redmond, WA

PostPosted: Wed Sep 14, 2005 4:01 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address MSN Messenger
TheSamuraiElephant



Joined: 04 Aug 2005
Posts: 17

PostPosted: Wed Sep 14, 2005 4:43 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group