cancel
Showing results for 
Search instead for 
Did you mean: 

problem with struct

wileti
Associate II
Posted on September 24, 2007 at 11:35

problem with struct

3 REPLIES 3
wileti
Associate II
Posted on September 17, 2007 at 20:30

Hi folks!

I´m struggling with a weird problem: there is a struct in my code like this:

extern struct {

int Flags : 3;

int Write : 2;

int Read : 3;

}TestData;

Afterwards compilation, I got this error:

#error clnk Debug\sugar_project.lkf:1 symbol _TestData not defined (Debug\bk.o Debug\hid.o Debug\main.o Debug\my_appli.o )

I don´t know why the compiler prompts this message. I´ve tried to declare this same struct outside (in a .c file, because it is an external struct), but in this case the message is:

#error cpst7 user_var.c:122(2+8) redeclared external TestData

Is my extern declaration correct?

This problem is getting me headache...

I´ll be very grateful for hints...

Thanks

Wilson

luca239955_st
Associate III
Posted on September 20, 2007 at 07:28

did you solve this? Looks like you never actually declared the structure itself...

wileti
Associate II
Posted on September 24, 2007 at 11:35

Yeah, I´ve already solved it.

What I did, in summary, was declare my struct in User_var.h like this:

struct _TestData{

unsigned char Flags : 3;

unsigned char Write : 2;

unsigned char Read : 3;

};

extern struct _TestData TestData;

In User_var.c it was declared suitable like this:

struct _TestData TestData;

After doing this, the error vanished!

Thanks a lot

Wilson