c++ - 有人如何定义数据类型,然后在数据类型定义之后立即在同一文件中包含的其他文件中使用它

标签 c++ compiler-errors compiler-construction c-preprocessor asn.1

我需要asn1 BER编码器/解码器,并发现它是“asn1c”编译器的一部分(这里是http://lionet.info/asn1c/blog/链接)。

我使用“配置,制作,安装”过程编译整个程序没有问题,但似乎无法单独编译。

我正在尝试将此包的BER编码器/解码器功能编译为NetBeans中的静态库。但是,我遇到一些“包含”废话的大问题。这是一个例子

在asn1parser.h文件中,有一个新类型的typedef,称为“asn1c_integer_t”

//some preprocessor statements removed to keep this post short...
typedef intmax_t asn1c_integer_t;


#include "asn1p_list.h"
#include "asn1p_oid.h"      /* Object identifiers (OIDs) */
#include "asn1p_ref.h"      /* References to custom types */
etc...

但是,先前文件中包含的某些文件(例如,asn1p_oid.h)正在使用先前文件中定义的新数据类型。
#ifndef ASN1_PARSER_OID_H
#define ASN1_PARSER_OID_H

typedef struct asn1p_oid_arc_s {
    asn1c_integer_t number; /* -1 if not yet defined */
    char *name; /* 0 if not defined */
} asn1p_oid_arc_t;
etc...

这对我来说毫无意义,而且我不断收到如下错误:

asn1parser.h:32: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘asn1c_integer_t’



谁能帮我解决这个问题?

最佳答案

您是否曾在“其中一些文件”中尝试过#include "asn1parser.h"?也许它们也包含在其他地方,到那时,名称asn1c_integer_t对编译器是未知的。

关于c++ - 有人如何定义数据类型,然后在数据类型定义之后立即在同一文件中包含的其他文件中使用它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5039780/

相关文章:

c++ - 在 C++ 中格式化电话号码

c++ - 如何在 gcc 上为 x86_64 启用 __fp16 类型

c++ - 错误 : use of deleted function when I try to use a reference

swing - 在Clojure中使用Swing-编译器异常: could not initialise RepaintManager

java - android系统类编译

Windows 的 C 编译器?

c++ - 如何在 C/CPP 中更改文件名和 ext

c++ - MPI all to all operation 一次只处理一个巨大矩阵的一部分

compiler-errors - 代码可以使用 netcore 编译,但不能使用 mono 编译

c++ - "No newline at end of file"编译器警告