EmbDev.net

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


Author: John Mayer (215)
Posted on:

Rate this post
0 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??

Author: RON (Guest)
Posted on:

Rate this post
0 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!

Author: John Mayer (215)
Posted on:

Rate this post
0 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
Author: Daniel Abrecht (daniel-a)
Posted on:

Rate this post
0 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)

Author: K&R reloaded (Guest)
Posted on:

Rate this post
0 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 ?

Author: John Mayer (215)
Posted on:

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

Author: Rolf Magnus (Guest)
Posted on:

Rate this post
0 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.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.