error: deferencing pointer to incomplete type
My prompt terminal give me:
Quote:
Quote:
error: deferencing pointer to incomplete type is referred at state pointer, what is error? Thanks |
Its a while since I did C, but I'm pretty sure you have to define the struct before you can reference it in a typedef (or anything else).
|
Quote:
Code:
typedef struct _SNotebook { |
It's been a long time for me, too, but you didn't tell us specifically which statement was giving the error, so I'm going to consider this as a test. This type of thing "&state->notebook" always caused me problems. I almost always had to rewrite it as either "&(state->notebook)" or even something like "(GtkNotebook *) &(state->notebook)". Like I said, it's been a long time.
|
@raconteur: indeed, but I've always preferred to keep 'em separate, especially if there's a danger needing more than one instance.
To me it's more K.I.S.S :) |
Quote:
That being said, I'm not quite sure I understand the above quote. [edit -- maybe I do, please see the last paragraph] Once a data type is defined, multiple instances are simple matter of declaration (and allocation if necessary), just like any other data type. For instance (no pun intended): Code:
typedef struct _SNotebook { The _Snotebook tag in the above definition is unnecessary in this case. The only time you need that type of tag is when you want to self-reference the type within the type itself (such as when you wish to create linked lists). Of course, having that tag there does no harm at all if it isn't used. The only odd thing you may see is that symbolic debuggers will usually display the type with the tag name. Here is an example of a self-referencing data type: Code:
typedef struct _SNotebook { However, in your case, with no self-referencing members in the struct, this definition would do just as well: Code:
typedef struct { If we really wanted to confuse things, we could point out that that things rather fundamentally change when the struct is only declared instead of being defined as a type. I won't go into all of that, K&R have done it very well. It occurs to me that those differences may be what chrism01 was saying. When multiple instances of a declared-only data structure are required, things can get verbose pretty quickly. |
All times are GMT -5. The time now is 04:26 AM. |