typedef-ed 枚举:数据定义没有类型或存储类

问题描述 投票:0回答:0

我收到以下错误消息:

./instruction.h:10:3: warning: data definition has no type or storage class
   10 | } OperandType;
      |   ^~~~~~~~~~~
./instruction.h:10:3: warning: type defaults to ‘int’ in declaration of ‘OperandType’ [-Wimplicit-int]
./instruction.h:15:3: error: expected specifier-qualifier-list before ‘OperandType’
   15 |   OperandType operand1_type;

编译代码时:

typedef enum{
  Integer,
  Label,
  Parameters,
  Register,
  None
} OperandType;

typedef struct{
  OperandType operand1_type;
  OperandType operand2_type;

  OperandType parameter1_type;
  OperandType parameter2_type;
} Instruction;

用这个命令:

gcc -o instruction instruction.c whitespace.o -Wall -ansi -pedantic

我该如何解决这个问题?

c enums typedef
© www.soinside.com 2019 - 2024. All rights reserved.