这是我的代码的一部分:
#ifndef INTPROC_OPERATIONS_H
#define INTPROC_OPERATIONS_H
#define MAX_OPERATIONS 256
#define USED_OPERATIONS 8
#define MAX_OPCODE 256
#define OPCODE_TYPE unsigned char
#define OPERANDS_TYPE unsigned char
#include <malloc.h>
#include "executions.h"
typedef struct
{
OPCODE_TYPE opcode;
const char * name;
OPERANDS_TYPE operands_length;
int (* execute)(char * operands_start, char operands_length);
} OPERATION;
OPERATION * operations[MAX_OPERATIONS];
extern void init_operations();
#define operations_init() init_operations()
extern OPERATION parse_operation(OPCODE_TYPE opcode); //syntax error type
#endif
代码.c
#include "code.h"
CODEFILE * create_file()
{
CODEFILE * ret = (CODEFILE*)malloc(sizeof(CODEFILE));
ret->actual_instruction = 0; //'actual_instruction' : is not a member of 'CODEFILE'
ret->length = 0; //'length' : is not a member of 'CODEFILE'
ret->name = ""; //'name' : is not a member of 'CODEFILE'
ret->start = 0; /'start' : is not a member of 'CODEFILE'
return ret;
}
注意:code.h 包含文件 operation.h,我已经骑过 somwhere 级联包含在使用 typedef 时可能会出现问题...
正如问题标题中所写,当我尝试编译此代码时,我从 Visual C++ 2010 收到 100 个错误。这些错误是由我的 typedef 中的一些错误引起的。
Error 95 error C2039: 'actual_instruction' : is not a member of 'CODEFILE'
Error 96 error C2039: 'length' : is not a member of 'CODEFILE'
Error 97 error C2039: 'name' : is not a member of 'CODEFILE'
Error 98 error C2039: 'start' : is not a member of 'CODEFILE'
...
Error 6 error C2059: syntax error : 'type'
Error 64 error C2059: syntax error : 'type'
Error 76 error C2059: syntax error : 'type'
包含此结构的头文件被包含在 C 文件中(我也在其他头文件中使用它)。错误之类syntax error : 'type'
的错误在包含文件中,其他错误在包含包含文件(包含成员)的文件中。有谁知道问题出在哪里?请帮忙。