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

我需要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对编译器是未知的。

https://stackoverflow.com/questions/5039780/

相关文章:

c++ - Netbeans 7.0编译器错误

c# - Visual C#中的奇怪编译错误

matlab - Matlab mex中状态码2的构建错误

java - 找不到符号—符号: method lastIndexOf(java.lang.Stri

xcode - 使用Xcode测试为Objective-C++代码库设置单元

c# - 添加动态评级控件时出现奇怪的编译问题

ios - 从GCC 4.2切换到LLVM 2.0时 ''中的 '-std='值无效

visual-studio-2010 - Visual Studio/TFS 2010/获取最新版本

c++ - C++中的模板类

gcc - C程序编译错误