Error: C received an "dereferencing a pointer to an incomplete type" error in the structure pointer

Hello everybody!

I got the following error while trying to check the code for Clever Frog: error: incomplete type dereference pointer

The "full code" is located on pastebin.com - here (it will not expire). But I think that with the explanation below, everyone can understand. Note. I have not yet implemented a function that will remove allocated memory and other things.

I have a structure defined in file 1.c:

#include "1.h"
...
struct test {
   int a;
   };
...

I have 1.h wicth using typedef:

...
typedef struct test testT;
...

Then I have a function that has a parameter in it depending on testT, which is located in 2.c:

...
void funcTest(testT **t, int *size, ..){
   /* another function that creates mem.space/alocate memory based enter code here`on the need of size above */
   createMem(t,*size); /* void createMem(testT **t, int size); */

   t[0]->a = 0; /*ERROR HERE*/
   /* ... more code ... */
}
...

The 2.h file is as follows:

...
void funcTest(testT **t, int *size, ..);
...

testT * var , :

...
testT *varTest; int size;

funcTest(&varTest, &size);
...

, , struct test 1.h ( struct test 1.c - ). , , t [0] → a.

"", :( , - , , - - , : D !

+3
5

a t[0] , (, , - a). struct test , 2.c, . , struct test.

struct test 1.h, , , .

1.h, .

+5

-

typedef struct test testT;

struct test {
   int a;
};

#includes. , testT, " ", , .

-, , "struct test", .

+3

, 1.c, 2.c, , . , , "", AFAIK, .

1.c, , struct test "a" 2.c.

- , , accessor/mutator. 2.c "" struct test, . C API.

( 1.c, 2.c, .)

+1

struct Test 1.c. t[0]->a , a. , shuld, !

, C/++ .c , , - .c.

Perhaps you should do the following:

(1.h)

struct test {
    int a;
};
...

(1.c)

#include "1.h"
...

(2.c)

#include "1.h"
...
void funcTest(testT **t, int *size, ..){
    createMem(t,*size); /* void createMem(testT **t, int size); */
    t[0]->a = 0;
    /* ... more code ... */
}
+1
source

But when you run the compiled program exactly where the error occurs, is the place t [0] → a.

The pointer to the allocated memory is actually located in *t, and not t(as seen from your code createMatrixin Pastebin), so you really should do:

(*t)[0].a

and similarly in your loop for:

(*matriz)[i].row
0
source

All Articles