我有这个问题:
causale char [256] Error: Multiple errors reported.\
Failed to execute MI command: -var-create - * &((lista).causale) Error message from debugger back end: Type struct list_element has no component named causale.\
Failed to execute MI command: -data-evaluate-expression (lista).causale Error message from debugger back end: There is no member named causale.\
Failed to execute MI command: -var-create - * &((lista).causale) Error message from debugger back end: Type struct list_element has no component named causale.\
Unable to create variable object
我不明白是否是Eclipse(用于C / C ++开发人员的Eclipse IDE版本:Juno Service Release 2)问题或我的代码中的错误。阅读错误报告似乎是我的代码中的错误,但我可以不能纠正它。任何人都可以帮助我吗?谢谢:))
这是我的代码: 的 MAIN.C
#include <stdio.h>
#include <stdlib.h>
#include "pagamenti.h"
int main ( )
{
char nomeFile [] = "20130613";
list l = NULL;
l = leggiPagamenti(nomeFile);
showList ( l );
system("PAUSE");
}
element.h展开
#ifndef ELEMENT_H_
#define ELEMENT_H_
typedef struct
{
int idCliente;
int idPagamento;
float importo;
char causale [ 256 ];
} Pagamento;
typedef Pagamento element;
#endif /* ELEMENT_H_ */
list.h
#ifndef LIST_H_
#define LIST_H_
#include "element.h"
typedef struct list_element {
element value;
struct list_element *next; } item;
typedef item* list;
typedef int boolean;
/* PROTOTIPI DI FUNZIONE (extern) */
/* PRIMITIVE */ list emptylist(void); boolean empty(list); list cons(element, list); element head(list); list tail(list); void showList(list l);
#endif /* LIST_H_ */
pagamenti.h
#ifndef PAGAMENTI_H_
#define PAGAMENTI_H_
#include "list.h"
list leggiPagamenti ( char *nomeFile );
#endif /* PAGAMENTI_H_ */
list.c
#include "element.h"
#include "list.h"
#define NULL 0
/* OPERAZIONI PRIMITIVE */
list emptylist(void) /* costruttore lista vuota */
{ return NULL; }
boolean empty(list l) /* verifica se lista vuota */
{ return (l==NULL); }
list cons(element e, list l)
{ list t; /* costruttore che aggiunge in testa alla lista */
t=(list)malloc(sizeof(item));
t->value=e;
t->next=l;
return(t);
}
element head(list l) /* selettore testa lista */
{ if (empty(l)) exit(-2);
else return (l->value);
}
list tail(list l) /* selettore coda lista */
{ if (empty(l)) exit(-1);
else return (l->next);
}
void showList(list l) {
// NON PRIMITIVE
printf("[");
while (!empty(l)) {
printf("id cliente : %d id pagamento : %d importo : %.2f causale : %s \n",head(l).idCliente,head(l).idPagamento,head(l).importo,head(l).causale );
l = tail(l);
} printf("]\n");
}
pagamenti.c
#include <stdio.h>
#include <stdlib.h>
#include "pagamenti.h"
#include "element.h"
list leggiPagamenti ( char *nomeFile )
{
element el ;
list lista = NULL;
FILE *f;
char car;
int count = 0;
if ( ( f = fopen ( nomeFile , "r") ) == NULL )
{
printf("Errore apertura file ");
exit ( 1 );
}
while ( ( fscanf (f,"%d %d %f ",&el.idCliente,&el.idPagamento,&el.importo))> 0 )
{
while ( ( car = fgetc(f)) != '\n' && ( car != EOF ))
{
el.causale[count] = car;
count++;
}
count = 0;
lista = cons ( el, lista );
}
fclose ( f );
return lista;
}
好的,在visual studio上运行相同的代码,可能是进入eclipse设置的问题