0

私のコードをコンパイルするときにサイズへのパスの無効なアプリケーションを取得していますが、自分で問題を見つけることができません。誰か助けてもらえますか?

/*********************************************************
* Node to represent a packet which includes a link reference*
* a link list of nodes with a pointer to a packet Struct    *

**********************************************************/
struct node {
unsigned int Source;
unsigned int Destination;
unsigned int Type;
int Port;
char *Data;
struct Packet *next;
 // Link to next packet

//unassigned int source
//unassigned int destination
//int type
//unassigned int port
//char *data
//struct node  *next link to next node
};

typedef struct Packet node; // Removes the need to constantly refer to struct


/*********************************************************
* Stubs to fully declared functions below                *
**********************************************************/
void Outpacket(node **head);
void push(node **head, node **aPacket);
node* pop(node **head);

int main() {

/*********************************************************
* pointers for the link list and the temporary packeyt to    *
* insert into the list                                   *
**********************************************************/
node *pPacket, *phead = NULL;

/*********************************************************
* Create a packet and also check the HEAP had room for it   *
**********************************************************/
pPacket = (node *)malloc(sizeof(node));
if (pPacket == NULL)
{
    printf("Error: Out of Memory\n");
    exit(1);
}

これは完全なコードのスニペットにすぎませんが、次の行でブレーク ポイントが発生します。

pPacket = (node *)malloc(sizeof(node));

助けてくれてありがとう

4

2 に答える 2

0

おそらくこれは、struct Packet定義せずに使用しているためです。

の定義ではstruct node、 を使用してstruct Packet*います。しかし、というものはありませんstruct Packed。構造体の名前を変更するか、要素を変更します。

以下を試してください:

struct Packet {
unsigned int Source;
unsigned int Destination;
unsigned int Type;
int Port;
char *Data;
struct Packet *next;
 // Link to next packet

//unassigned int source
//unassigned int destination
//int type
//unassigned int port
//char *data
//struct node  *next link to next node
};

typedef struct Packet node; // Removes the need to constantly refer to struct

ここで、struct Packetnodeは同じ構造で異常はありません。

于 2013-04-25T11:04:57.800 に答える