错误:之前的预期说明符限定符列表

时间:2012-10-07 22:03:17

标签: c

我正在尝试编译一个项目,并且在头文件中引发了一个错误(唯一的错误)。

error: expected specifier-qualifier-list before ‘draw’

可以在此处找到有问题的代码行:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define LNAME 129 
#define DNUM 17 

typedef struct {
  char name[LNAME]; 
  double x[DNUM];        
  double y[DNUM];        
  double x_point[DNUM];  
  double y_point[DNUM];
  int draw;                 
  draw = 1;                         //<< the line GCC references in the error for reference
  memset(name, 0, sizeof(name));
  memset(x, 0, sizeof(x));
  memset(y, 0, sizeof(y));
} Figure;

我对C很陌生,所以如果有人能提供一些见解,我会很感激。

1 个答案:

答案 0 :(得分:0)

您无法为结构成员提供初始值。您必须编写构造函数来初始化结构的特定实例中的所有成员。