Forum : 8051
Original Post
Post Information | Post |
---|---|
March 29, 2007 - 6:59pm
|
Hello everybody, My problem is that I have a: typedef union and after I want to use this typedef union insido of another typedef union. typedef struct _SHORT_ADDR typedef union _ADDR Well, I want to use SHOR_ADDR inside of ADDR typedef and the compiler gives the C144 ERROR. How could I solve this? Thanks! |
{
SHORTADDR LongAddr;
SHORT_ADDR ShortAddr;
BYTE v[8];
} ADDR[/pre]
you have no definition of LONG_ADDR
I made a mistake in the first post but in my program it is rigth, well the program is:
typedef struct _LONG_ADDR
{
BYTE v[8];
} LONG_ADDR;
typedef struct _SHORT_ADDR
{
struct _SHORT_ADDR_bits
{
BYTE MSB;
BYTE LSB;
} byte;
WORD Val;
BYTE v[2];
} SHORT_ADDR;
typedef union _ADDR
{
LONG_ADDR LongAddr;
SHORT_ADDR ShortAddr;
BYTE v[8];
} ADDR;
could it be
you are making a union of two identical entities
LONG_ADDR contains BYTE v[8]; and you repeat that in the union, just as a test try removing BYTE v[8]; from the union, if that works, experiment from there.
Erik
Hi erikm thanks for yours proporsals!
I think that I have found the solution, the problem is not the definition of the "typedef struct" inside of another type struct. The problem is that I am calling the #include "file.h" where the LONG_ADDR,SHORT_ADDR and ADDR are defined twice. I have made the experiment only with the main with only #include "file.h" and nothing more and everthing was rigth, no errors. But after I tryed put the sentence #include "file.h" twice
#include "file.h"
#include "file.h"
void main(void)
{}
then the error appears.
My program have some files and maybe I am calling #include "file.h" in two diferent files and this files are called from the main too.
have you tried what many do (I do not)
for every .h file you write
#ifndef HFILENAME
#define HFILENAME
the guts of the file
#endif
That way any .h file will only be included once, however you make your code
Thanks again Erikm!!
I usually do this (put #ifndef HFILENAME ....) with my "xxx.h" files but this time I didn't and I think that will save me time.
Thanks
Santi
The one thing we all have been bitten by several time is "I usually do this ... but this time I didn't ".
When some habit is ingrained and you skip it, you never think that the reason you see something is because of xxx, because you 'always' make xxx impossible.
Erik