struct instance "undeclared" (first use in this function)

This is a discussion on struct instance "undeclared" (first use in this function) within the C Programming forums, part of the General Programming Boards category; I'm having trouble getting some code to compile...the following code gives me the error: 'Chunk' undeclared (first use in this ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    3

    struct instance "undeclared" (first use in this function)

    I'm having trouble getting some code to compile...the following code gives me the error:
    'Chunk' undeclared (first use in this function)
    when compiled with "make" in cygwin.

    Code:
    //create structure for holding chunk data
    struct Chunk
    {
    	unsigned short ID; //first two bytes
    	unsigned int size; //last four bytes
    };
    
    int main() {
            pspDebugScreenInit();
            SetupCallbacks(); 
            printf("3DS Loader version 0.1\n");
            printf("======================\n");
            printf("by David Reicher\n");
    
    	//setup file name
            char* filename;
    	filename = "ms0:/xwing.3ds";
    	int fdin;
    	
    
    	//open file and start reading
    	fdin = sceIoOpen(filename, PSP_O_RDONLY, 0777);
    	if(fdin >= 0)
    	{
    		printf("File opened %s\n\n", filename);
    		
    		
    		Chunk firstChunk;
    
    		int bytes_read = 1;
    		bytes_read = sceIoRead(fdin, &firstChunk->ID, sizeof(firstChunk->ID));
    		printf("ID: 0x%x\n", firstChunk.ID);
    		bytes_read = sceIoRead(fdin, &firstChunk->size, sizeof(firstChunk->size));
    		printf("Chunksize: %u\n", firstchunk.size);
    	}
    	else
    	{
    		printf("Couldn't open %s\n", filename);
    	}
    
    
    	//wait for home button push, then exit
            sceKernelSleepThread();
            return 0;
    }
    I know I'm probably doing something stupid (I'm kind of a newbie), but could anyone give me some advice on where I'm going wrong?

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    Code:
    Chunk firstChunk;
    should be
    Code:
    struct Chunk firstChunk;

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    3
    Thanks its working fine now (also the last "firstchunk" used should have been "firstChunk").

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 07:54 PM
  2. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21