Моя IDE — C-free 5.0, компилятор — MinGW.
У меня есть два файла: 'list.h', 'list.c'
список.ч:
typedef int elementType;
#ifndef _LIST_H
#define _LIST_H
struct node;
typedef struct node* ptrToNode;
typedef ptrToNode list;
typedef ptrToNode position;
list makeEmpty(list l);
#endif
список.с:
#include <stdio.h>
#include "list.h"
#include <stdlib.h>
struct node{
elementType element;
position next;
};
list makeEmpty(list l){
if(l == NULL){
//delete list
}
l = malloc(sizeof(struct node));
if(l == NULL){
printf("fail to malloc memory");
exit(-1);
}
l->next = NULL;
return l;
}
Я пытаюсь скомпилировать эти файлы, но получаю ошибку
"list.c:5: redefinition of 'struct node'"
Затем я заменил все "node" на "Node", и произошли удивительные вещи! Сборка в порядке! Я действительно не могу понять это. Это может быть связано с библиотекой C?
node
, либо всеNode
. Нет никакой магии... - person Nim   schedule 25.06.2012