error: storage size of 'frm' isn't known

W

walsht

When I compile the code snipets below I'm producing the error: storage
size of 'frm' isn't known.

dll.h :
/*
* File: dll.cpp
* Defines the data link layer's interface.
*/

#ifndef __FRAME_
#define __FRAME_

typedef unsigned int frame_kind;
typedef unsigned int seq_nr;

struct {
frame_kind kind;
seq_nr seq;
seq_nr ack;
char data[100];
}; frame

#endif

dataLinkSend() :
void dataLinkSend(int sd, char* data, seq_nr last) {
struct frame frm;

frm.kind = data;
frm.seq = (last++)%3;
frm.ack = last;
frm.data = data;

if(send(sd, frm, sizeof(frm), 0) < 0) {
fprintf(stderr, "Couldn't send frm\n");
exit(1);
}
}

If you need the whole file that dataLinkSend() id in, let me know and I
can post it.
 
R

Richard Heathfield

(e-mail address removed) said:

struct {
frame_kind kind;
seq_nr seq;
seq_nr ack;
char data[100];
}; frame

Shift the tag:

struct frame {
frame_kind kind;
seq_nr seq;
seq_nr ack;
char data[100];
};
 
M

Michael Mair

When I compile the code snipets below I'm producing the error: storage
size of 'frm' isn't known.

Please provide a compiling minimal example inserted in your
message by copy and paste. Otherwise, important information
or the error itself may be missing or people may spot errors
that were not there in the original version.
typedef unsigned int frame_kind;
typedef unsigned int seq_nr;

struct {
frame_kind kind;
seq_nr seq;
seq_nr ack;
char data[100];
}; frame

This must not compile.

You mean:
struct frame {
....
};

dataLinkSend() :
void dataLinkSend(int sd, char* data, seq_nr last) {
struct frame frm;

As you did not really create the type "struct frame" above,
this type is not known, and so is its size...

<snip>


Cheers
Michael
 
W

walsht

I got it working now. Thanks everyone.

Tim

Michael said:
When I compile the code snipets below I'm producing the error: storage
size of 'frm' isn't known.

Please provide a compiling minimal example inserted in your
message by copy and paste. Otherwise, important information
or the error itself may be missing or people may spot errors
that were not there in the original version.
typedef unsigned int frame_kind;
typedef unsigned int seq_nr;

struct {
frame_kind kind;
seq_nr seq;
seq_nr ack;
char data[100];
}; frame

This must not compile.

You mean:
struct frame {
....
};

dataLinkSend() :
void dataLinkSend(int sd, char* data, seq_nr last) {
struct frame frm;

As you did not really create the type "struct frame" above,
this type is not known, and so is its size...

<snip>


Cheers
Michael
 
J

Joe Wright

When I compile the code snipets below I'm producing the error: storage
size of 'frm' isn't known.

dll.h :
/*
* File: dll.cpp
* Defines the data link layer's interface.
*/

#ifndef __FRAME_
#define __FRAME_

typedef unsigned int frame_kind;
typedef unsigned int seq_nr;

struct {
frame_kind kind;
seq_nr seq;
seq_nr ack;
char data[100];
}; frame

#endif

dataLinkSend() :
void dataLinkSend(int sd, char* data, seq_nr last) {
struct frame frm;

frm.kind = data;
frm.seq = (last++)%3;
frm.ack = last;
frm.data = data;

if(send(sd, frm, sizeof(frm), 0) < 0) {
fprintf(stderr, "Couldn't send frm\n");
exit(1);
}
}

If you need the whole file that dataLinkSend() id in, let me know and I
can post it.
I suppose it could be more complex than this but..

struct {
frame_kind kind;
seq_nr seq;
seq_nr ack;
char data[100];
}; frame
^
...kills it for me. Should be..

struct {
frame_kind kind;
seq_nr seq;
seq_nr ack;
char data[100];
} frame;
^
 
J

Joe Wright

Joe said:
When I compile the code snipets below I'm producing the error: storage
size of 'frm' isn't known.

dll.h :
/*
* File: dll.cpp
* Defines the data link layer's interface.
*/

#ifndef __FRAME_
#define __FRAME_

typedef unsigned int frame_kind;
typedef unsigned int seq_nr;

struct {
frame_kind kind;
seq_nr seq;
seq_nr ack;
char data[100];
}; frame

#endif

dataLinkSend() :
void dataLinkSend(int sd, char* data, seq_nr last) {
struct frame frm;

frm.kind = data;
frm.seq = (last++)%3;
frm.ack = last;
frm.data = data;

if(send(sd, frm, sizeof(frm), 0) < 0) {
fprintf(stderr, "Couldn't send frm\n");
exit(1);
}
}

If you need the whole file that dataLinkSend() id in, let me know and I
can post it.
I suppose it could be more complex than this but..

struct {
frame_kind kind;
seq_nr seq;
seq_nr ack;
char data[100];
}; frame
^
..kills it for me. Should be..

struct {
frame_kind kind;
seq_nr seq;
seq_nr ack;
char data[100];
} frame;
^
This was a mistake. I need more rest. Should be..

struct frame {
frame_kind kind;
seq_nr seq;
seq_nr ack;
char data[100];
};

I'll go lie down now. See y'all later.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top