Undeclared identifier driving me nuts

Before I start let me state that the program is in C (not C++).

I find myself unable to eliminate this error about undeclared identifier and it's driving me nut. I have declared a structure that I use to declare an array like this:

1
2
3
4
5
struct tab_sub
{ 
	int nb;
	ptr_sub ptr;
};

typedef struct tab_sub * ptr_tab_sub;

I then use said typedef to declare said array with a malloc like so :
pre_tab_sub table_sub = malloc(nb_sub * sizeof(*table_sub));

Where nb_sub is a "loose" variable that will be passed to the function to allocate enough memory for the array.

now having this new array of variable size I allocate each sub with its info like so:

sub1->info1
sub2->info2
etc.

The funny thing is that all that work just fine but then come the really odd part. Back in the main I declare a handle with the typedef of that arrayptr_tab_sub holder; in hope to pass it the address of the first element of the newly declared array so I can manipulate data and such.

but apparently, ptr_tab_sub is not considered an identifier. Which I find really odd since in the header and the .c there doesn't seem to be any problem. (and no, everything is included correctly).
pre_tab_sub table_sub I'm assuming that's really ptr_tab_sub and not pre_tab_sub in your code.

Anyway, no reason for an invalid identifier error unless it's an invalid identifier. You said everything is included correctly, but it must not be or else you wouldn't be getting this error.
I feel like a complete idiot. I poke a bit around and apparently my compiler was using the wrong header file (.h) with the right name. Thanks you for the comment though, it made me go back and verify again correctly and I am also sorry for wasting time on such trivialities (that siphoned couple of hours of coding, arg...)
Topic archived. No new replies allowed.