EmbDev.net

Forum: µC & Digital Electronics struct within multiple struct causing problems


von John M. (215)


Rate this post
useful
not useful
I have a struct which is beeing included to other struct in other 
modules, such as StructA.StructB.ElementofB is possible.

This is done for multiple modules, and each module has the .h file of 
structB included.  But for some reason am i getting compiler errors 
which says that structB is an undefined type, eventthoug i in my IDE can 
see that it is declarated correctly.

Why is it saying that the type is undefined eventhough i've included the 
.h file??

von RON (Guest)


Rate this post
useful
not useful
John Mayer wrote:
> I have a struct which is beeing included to other struct in other

Maske an example of the complex struct with same datatypes!

von John M. (215)


Rate this post
useful
not useful
typedef struct{
int start;
int stop;
int lap;
} a;


typedef struct{
a A
int car;
int postal;
} loser;



typedef struct{
a A
int don;
int son;
} more;


each struct is in it's own .h file. i've just included .h of struct a on 
all them.

: Edited by User
von Daniel A. (daniel-a)


Rate this post
useful
not useful
I can't find a mistake in the example, i think the problem is somewere 
else. How is the exact structure of the files, in which order are 
#include and #ifdef - #endif and in which files? Try to preprocess the 
files only, then something may be clearer. (gcc -E file.c)

von K&R reloaded (Guest)


Rate this post
useful
not useful
Daniel A. wrote:
> I can't find a mistake in the example

I can!  What about a semikolon after the "a A"  line ?

von John M. (215)


Rate this post
useful
not useful
Well. that's just because i just wrote some random ones here..
they are added in my code.

von Rolf Magnus (Guest)


Rate this post
useful
not useful
John Mayer wrote:
> Well. that's just because i just wrote some random ones here..
> they are added in my code.

You are not supposed to write some random code for this posting, but 
something that you tried and that actually contains the problem you're 
experiencing.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.