全部博文(132)
分类: C/C++
2009-02-20 13:31:58
#
| |||
| |||
Re: compile error: storage size of 'var' isn't known
George wrote: :: Hello everyone, :: :: :: I get a strange compile error when compile such simple program. Any :: ideas? :: :: foo.c: In function `main': :: foo.c:5: error: storage size of 'var' isn't known The compiler can figure out that 'var' is of type 't_st', which is another name for a struct named 'st'. However, it cannot see what 'st' is, as it is hidden in another translation unit. You can have a pointer to st without knowing exactly what it is, but you cannot have a variable of type st without seeing the full definition. Bo Persson :: :: foo.c :: :: Expand|Select|Wrap|Line Numbers
:: goo.c :: :: Expand|Select|Wrap|Line Numbers
:: goo.h :: :: Expand|Select|Wrap|Line Numbers
:: :: thanks in advance, :: George |
#
| |||
| |||
Re: compile error: storage size of 'var' isn't known
Thanks Bo Persson! I want to confirm that, if I define a struct in .c file, I can only use the struct in the same .c file, and have no walk-around to utilize the struct in other .c file. If I want to use the struct in multiple .c files, I have to define it in .h file? regards, George "Bo Persson" wrote: Quote:
|
#
| |||
| |||
Re: compile error: storage size of 'var' isn't known
George wrote: :: Thanks Bo Persson! :: :: :: I want to confirm that, if I define a struct in .c file, I can only :: use the struct in the same .c file, and have no walk-around to :: utilize the struct in other .c file. The "work-around" is to define the struct identically in both .c files. That in effect simulates what happens when you include a .h file in both .c files. Not recommended! :-) :: :: If I want to use the struct in multiple .c files, I have to define :: it in .h file? This is the reason for having .h files in the first place. It lets you share declarations between several implementation files. Bo Persson |
When I compile the code snipets below I'm producing the error: storage
size of 'frm' isn't known.
typedef unsigned int frame_kind;
typedef unsigned int seq_nr;
struct {
frame_kind kind;
seq_nr seq;
seq_nr ack;
char data[100];
}; frame
dataLinkSend() :
void dataLinkSend(int sd, char* data, seq_nr last) {
struct frame frm;