GCC的编译错误
来源:百度知道 编辑:UC知道 时间:2024/05/26 18:54:33
照着书上写了一个小程序如下:
#include<stdio.h>
/*函数结果状态代码,Status是函数的类型,其值是函数结果状态代码*/
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOWED -2
#define LIST_INIT_SIZE 100 /*线性表存储空间的初始分配量*/
#define LIST_INCREAMENT 10 /*线性表存储空间的分配增量*/
typedef int Status;
typedef int ElemType;
typedef struct
{
ElemType *elem;
int length;
int listsize;
}SqList;
//Status InitList_Sq(SqList &L);
int main()
{
return 0;
}
Status InitList_Sq(SqList &L)
{
L.elem=(ElemType *)malloc(LIST_INIT_SIZE*sizeof(ElemType));
L.listsize=LIST_INIT_SIZE;
L.length=0;
return OK;
}
语法上应该是没有错误的,可是gcc编译的时候无法通过显示的出错信息如下:
expected ‘;’, ‘,’ or ‘)’ before ‘&’ token
网上搜寻许久,没有答案阿。。。。。。。。。。。。高人帮忙解答一下哈!
#include<stdio.h>
/*函数结果状态代码,Status是函数的类型,其值是函数结果状态代码*/
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOWED -2
#define LIST_INIT_SIZE 100 /*线性表存储空间的初始分配量*/
#define LIST_INCREAMENT 10 /*线性表存储空间的分配增量*/
typedef int Status;
typedef int ElemType;
typedef struct
{
ElemType *elem;
int length;
int listsize;
}SqList;
//Status InitList_Sq(SqList &L);
int main()
{
return 0;
}
Status InitList_Sq(SqList &L)
{
L.elem=(ElemType *)malloc(LIST_INIT_SIZE*sizeof(ElemType));
L.listsize=LIST_INIT_SIZE;
L.length=0;
return OK;
}
语法上应该是没有错误的,可是gcc编译的时候无法通过显示的出错信息如下:
expected ‘;’, ‘,’ or ‘)’ before ‘&’ token
网上搜寻许久,没有答案阿。。。。。。。。。。。。高人帮忙解答一下哈!
#include<stdio.h>
#include<stdlib.h>/*用到了malloc()函数,所以要包含此文件*/
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOWED -2
#define LIST_INIT_SIZE 100
#define LIST_INCREAMENT 10
typedef int Status;
typedef int ElemType;
typedef struct
{
ElemType *elem;
int length;
int listsize;
}SqList;
int main()
{
return 0;
}
Status InitList_Sq(SqList *L)/*注意这里,这是一段C程序,C语言不支持引用*/
{
L->elem=(ElemType *)malloc(LIST_INIT_SIZE*sizeof(ElemType));/*注意这里*/
L->listsize=LIST_INIT_SIZE;/*注意这里*/
L->length=0;/*注意这里*/
return OK;
}