我正在尝试编译一个包含 Middlc.h 的文件 Args.c。Middlc.h 错误给出以下错误。
enter code here
Middlc.h:23:1: error: pasting "*" and "ArgList" does not give a valid preprocessing token
Middlc.h:24:1: error: pasting "*" and "CandidateList" does not give a valid preprocessing token
Middlc.h:25:1: error: pasting "*" and "Decl" does not give a valid preprocessing token
Middlc.h:26:1: error: pasting "*" and "DeclList" does not give a valid preprocessing token
Middlc.h:27:1: error: pasting "*" and "ExcList" does not give a valid preprocessing token
Middlc.h:28:1: error: pasting "*" and "Field" does not give a valid preprocessing token
Middlc.h:29:1: error: pasting "*" and "FieldList" does not give a valid preprocessing token
Middlc.h:30:1: error: pasting "*" and "Identifier" does not give a valid preprocessing token
Middlc.h:31:1: error: pasting "*" and "IdentifierList" does not give a valid preprocessing token
Middlc.h:32:1: error: pasting "*" and "Interface" does not give a valid preprocessing token
Middlc.h:33:1: error: pasting "*" and "InterfaceList" does not give a valid preprocessing token
Middlc.h:34:1: error: pasting "*" and "Spec" does not give a valid preprocessing token
Middlc.h:35:1: error: pasting "*" and "SymbolTable" does not give a valid preprocessing token
Middlc.h:36:1: error: pasting "*" and "ScopedName" does not give a valid preprocessing token
Middlc.h:37:1: error: pasting "*" and "Type" does not give a valid preprocessing token
Middlc.h:38:1: error: pasting "*" and "TypeList" does not give a valid preprocessing token
Middlc.h:39:1: error: pasting "*" and "FileStack" does not give a valid preprocessing token
即使解决了单个错误,它也会非常有帮助。我可以在此基础上解决其他的。
这是代码:
中间件
#ifndef _Middlc_h_
#define _Middlc_h_
/*
* Main header file for Middlc.
*/
#define PY(x) printf x
#define new(x) ((x##_t)malloc(sizeof(struct _##x##_t)))
#define TYPE_DECL(x) typedef struct _##x##_t *##x##_t
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
typedef enum { False, True } bool_t;
#define MAX_STRING_LENGTH 1024
TYPE_DECL(ArgList);
TYPE_DECL(CandidateList);
TYPE_DECL(Decl);
TYPE_DECL(DeclList);
TYPE_DECL(ExcList);
TYPE_DECL(Field);
TYPE_DECL(FieldList);
TYPE_DECL(Identifier);
TYPE_DECL(IdentifierList);
TYPE_DECL(Interface);
TYPE_DECL(InterfaceList);
TYPE_DECL(Spec);
TYPE_DECL(SymbolTable);
TYPE_DECL(ScopedName);
TYPE_DECL(Type);
TYPE_DECL(TypeList);
TYPE_DECL(FileStack);
#include "FileStack.h"
#include "SymbolTable.h"
#include "Modes.h"
#include "Decls.h"
#include "Types.h"
#include "Args.h"
#include "Candidates.h"
#include "Exceptions.h"
#include "Fields.h"
#include "Identifiers.h"
#include "Interfaces.h"
#include "Specs.h"
#include "ScopedNames.h"
#include "Parser.h"
#include "Globals.h"
#include "Errors.h"
#endif /* _Middlc_h_ */