You are not logged in.
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
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
"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.
Offline
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
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
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