You are not logged in.

#1 2012-05-17 02:41:13

Jordanlw
Member
Registered: 2010-07-27
Posts: 44

[SOLVED]"dereferencing pointer to incomplete type" GCC

Hello,
I'm when I compile my program I get this error from GCC:

callbacks.c: In function ‘g2DCallback’:
callbacks.c:32: error: dereferencing pointer to incomplete type

Here's the code for callbacks.c:

#include <unistd.h>
#include <ppapi/c/ppb_input_event.h>
#include <ppapi/c/pp_errors.h>
#include <ppapi/c/ppb_graphics_2d.h>
#include <ppapi/c/pp_resource.h>

#include "header/sdlstore.h"
#include "header/main.h"
#include "header/callbacks.h"

void g2DCallback(void *data,int32_t result)
{
	struct PPB_Graphics2D *g2DInterface = (struct PPB_Graphics2D *)sdlStore(NULL,GET_2D_INTERFACE);
	//struct g2DCallbackData *readyData = (struct g2DCallbackData *)data;
	/*PP_Resource screen = */g2DInterface->Create();
	//readyData->instance,readyData->size,readyData->flag);
	//sdlStore((void *)&screen,SET_SCREEN);
	return;
}

I'm using Native Client. The ppb_graphics_2d.h file contains the definition for "struct PPB_Graphics2D".

Thanks.

Last edited by Jordanlw (2012-05-17 14:48:27)

Offline

#2 2012-05-17 12:03:39

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,532
Website

Re: [SOLVED]"dereferencing pointer to incomplete type" GCC

What about sdlStore?  I can't find any documentation for that.  From the includes it looks like something you may have written.  Attach or link that code as well, I suspect that is where the problem is.  Does sdlStore properly set the Create function pointer?

Also, Create requires 3 arguments, doesn't it?

Edit: I also wonder whether adding NaCl/Pepper to the title would draw people more qualified than me.

Last edited by Trilby (2012-05-17 12:31:58)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2012-05-17 13:19:10

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: [SOLVED]"dereferencing pointer to incomplete type" GCC

"dereferencing pointer to incomplete type" means you are trying to access something in a struct that hasn't been defined yet. It's been declared, but not defined.

For example, you can say:

typedef struct DOG DOG; // Declaration
DOG *doggy;

And you can use "doggy", but as soon as you try to access something inside it, for example:

if (doggy->color == GOLDEN)
  return;

Then the compiler will HATE YOU, because it doesn't know a DOG has a color, even though it knows about the concept of a "DOG".

A definition, of course, would look like this:

struct DOG // Definition
{
  char name[20];
  int color;
};

Anyway, you didn't post enough code to allow anyone to help you fix it. For example, the error is on line 32 but there's no line 32. tongue

Offline

#4 2012-05-17 13:54:10

Jordanlw
Member
Registered: 2010-07-27
Posts: 44

Re: [SOLVED]"dereferencing pointer to incomplete type" GCC

Hello,
Sorry for not posting more information, here's the complete source: https://github.com/Jordanlw/OsmosClone/tree/nacl
Here's the source code for ppb_graphics_2d.h: http://pastebin.com/RskGKb6g

Thanks.

Offline

#5 2012-05-17 14:38:01

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: [SOLVED]"dereferencing pointer to incomplete type" GCC

This is getting confusing. I checked out the git code. It compiled cleanly, so I assume you have the problem code in a local branch. Is the problem still on line 32?

I assume this is the line that's not compiling:

struct PPB_Graphics2D *g2DInterface = (struct PPB_Graphics2D *)sdlStore(NULL,GET_2D_INTERFACE);

As far as I can tell, there is no "struct PPB_Graphics2D" structure defined anywhere, only a "PPB_Graphics2D" typedef. In other words, delete the word "struct". I'm not sure if that's the problem, though, because I can't compile it.

Are you familiar with the difference between the "struct" and "typedef" namespaces?

Offline

#6 2012-05-17 14:47:57

Jordanlw
Member
Registered: 2010-07-27
Posts: 44

Re: [SOLVED]"dereferencing pointer to incomplete type" GCC

Thank you, after fixing that problem it now compiles, I kept looking over the code bit by bit (relevant parts at least) and I couldn't see an issue, didn't even think to remove the struct prefix, luckily now that I'm alert, this wont happen again.
Thanks.

Offline

Board footer

Powered by FluxBB