[LCP] How get around "dereferencing pointer to incomplete type" error?
geckoneS hilst
danielhilst at gmail.com
Fri Dec 25 22:55:11 EST 2009
I just want to put the include switch where it would be,
but I got a "derefencing pointer to implete type".. here is the code
-------------- FILE.C----------------------
#define STRCT_TYPE typeofstrct
#include <stdio.h>
// #include "libst.h" // <- I want it here
struct typeofstrct {
struct strct * next;
struct strct * prev;
char * data;
} strct;
#include "libst.h"
int
main (void)
{
strct.data = "Hello World";
stack_strct_init (& strct, sizeof (strct) );
printf ("%s\n", ((struct typeofstrct *) FirstItem) -> data);
return 0;
}
-----------FILE.C---------------------------------------------
----------LIBST.H--------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static void * FirstItem = NULL;
static void * LastItem = NULL;
static void * StrctPtr = NULL;
static size_t SizeOfStrct;
void
stack_strct_init (void * argptr, size_t siz)
{
StrctPtr = argptr;
SizeOfStrct = siz;
void * newpool = malloc (SizeOfStrct);
if (newpool == NULL)
exit (EXIT_FAILURE);
FirstItem = newpool;
memcpy (FirstItem, StrctPtr, SizeOfStrct);
((struct STRCT_TYPE *) FirstItem) -> next = NULL;
((struct STRCT_TYPE *) FirstItem) -> prev = NULL;
}
----------LIBST.H--------------------------------------------
More information about the linuxCprogramming
mailing list