发新话题
打印

谁来帮我看看这段程序啊~~~~

谁来帮我看看这段程序啊~~~~

我在用YACC写编译器的时候,遇到一个很奇怪的问题,以下是我的declare.h文件
复制内容到剪贴板
代码:
# include <stdio.h>

/* gate types */
# define INPT 1
# define BUFF 2  
# define NOT 3
# define AND 4
# define NAND 5
# define OR               6
# define NOR 7
# define FAN  8
# define MAXGATES    20000

/* structure for gates */
typedef struct {
    unsigned gtype :4;  /* gate type */
    unsigned name :15;
    unsigned source;
    unsigned short fanin;  /* fanin count */
    unsigned short fanout; /* fanout count */
    struct lnode *outlist;  /* fanout list */
    struct lnode *inlist;   /* input list */
} GNODE;


/* structure for ordinary lists */
typedef struct lnode {
    unsigned nnum : 24;
    unsigned timeframe : 8;
    struct lnode *nextnode;
} LNODE;

GNODE gate[MAXGATES]; /* the circuit graph */

unsigned gatenum, /* number of gates */
然后在和parse.y一起用make编译的时候,GCC老是给我如下提示:& ~1 W9 U3 J) g
error: 'LNODE' redeclared as different kind of symbol# [# i! g2 m2 P+ N
LNODE是我在parse.y第一部分里出现的定义,第一部分如下:
复制内容到剪贴板
代码:
%{
#include "declare.h"

LNODE *node;
int origin, record;  
struct {
    char *symbol;
    int val;
} symtab1[] = { "PI", INPT,
         "buff", BUFF,
  "FAN", FAN,
  "not",  NOT,
  "and",  AND,
  "or",   OR,
  "nor"   NOR,
  "nand", NAND,
  0,  0
     };
%}

%token COMMENT GTYPE FANOUT NUM NAME
%token FANIN INPUT FAULT
%%
它的意思好象是我的LNODE有重复定义了,但是我实在看不出哪里还有定义过啊,都快找疯,大牛们帮我看看吧,谢谢拉      

TOP

复制内容到剪贴板
代码:
unsigned gatenum[color=red],[/color] /* number of gates */
unsigned gatenum[color=red];[/color] /* number of gates */
      
'
梅须逊雪三分白 雪却输梅一段香

TOP

发新话题