【问题标题】:add ASN.1 generated class to C project [closed]将 ASN.1 生成的类添加到 C 项目 [关闭]
【发布时间】:2014-05-10 14:19:02
【问题描述】:

我使用这个编译器 lionet.info/asn1c 从 ASN.1 描述中生成了一些 C 类。当我尝试使用 GCC 编译代码时出现错误,这是其中的一部分

在 asn_application.h:45 包含的文件中, 来自 client.c:10: constr_TYPE.h:15:28: 错误: ber_tlv_length.h: 没有这样的文件或目录 constr_TYPE.h:16:25: 错误:ber_tlv_tag.h:在包含的文件中没有这样的文件或目录 asn_application.h:45, 来自 client.c:10: constr_TYPE.h:35: 错误: 'ber_tlv_len_t' 之前的预期说明符限定符列表 constr_TYPE.h:38:60: 错误:ber_decoder.h:没有这样的文件或目录 constr_TYPE.h:39:68: 错误:der_encoder.h:没有这样的文件或目录 constr_TYPE.h:40:58: 错误:xer_decoder.h:没有这样的文件或目录 constr_TYPE.h:41:60: 错误:xer_encoder.h:没有这样的文件或目录 constr_TYPE.h:42:61: 错误:per_decoder.h:没有这样的文件或目录 constr_TYPE.h:43:61: 错误:per_encoder.h:没有这样的文件或目录 constr_TYPE.h:44:59: 错误:constraints.h:没有这样的文件或目录 constr_TYPE.h:77: 错误:“ber_tlv_tag_t”之前的预期声明说明符或“...” constr_TYPE.h:77:错误:“ber_tlv_tag_t”声明为函数 返回一个函数 constr_TYPE.h:77:警告:参数名称 (无类型)在函数声明 constr_TYPE.h:79: 错误: 之前应为“=”、“,”、“;”、“asm”或“attribute” ‘asn_TYPE_outmost_tag’ constr_TYPE.h:95:错误:预期 “asn_constr_check_f”之前的说明符限定符列表 constr_TYPE.h:144:错误:字段“标签”声明为函数 constr_TYPE.h:147:错误:预期的说明符限定符列表之前 ‘asn_constr_check_f’ constr_TYPE.h:157:错误:声明了字段‘el_tag’ 作为函数在 client.c:11 中包含的文件中: asn_codecs_prim.h:8:29: 错误: asn_application.h: 没有这样的文件或 目录在 client.c:11 中包含的文件中:asn_codecs_prim.h:20: 错误:之前应为“=”、“,”、“;”、“asm”或“attribute” 'ber_decode_primitive' asn_codecs_prim.h:21:错误:预期的'=',',', ‘;’, ‘asm’ or ‘attribute’ before ‘der_encode_primitive’ 在文件中 包含在 client.c:15: ber_decoder.h:56: error: 预期 “ber_tlv_len_t”之前的声明说明符或“...”

在 eclip a got

调用:GCC C 编译器 gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/BIT_STRING.d" -MT"src/BIT_STRING.d" -o "src/BIT_STRING.o" "../src/BIT_STRING.c" ../src/BIT_STRING.c:5: 26:警告: asn_internal.h:没有这样的文件或目录 ../src/BIT_STRING.c:6:24: 警告:BIT_STRING.h:没有这样的文件或目录 ../src/BIT_STRING.c:12:错误:预期的'=',',',';','asm'或 “asn_DEF_BIT_STRING_tags”之前的“属性” ../src/BIT_STRING.c:15: 错误: 预期'=', ',', ';', 'asm' 或 'asn_DEF_BIT_STRING_specs' 之前的 'attribute' ../src/BIT_STRING.c:20: 错误: 预期的 '=', ',', ';', 'asm' 或 'asn_DEF_BIT_STRING' 之前的'属性' ../src/BIT_STRING.c:48: 错误:在 '' 标记之前预期 ')' ../src/BIT_STRING.c:76: 错误: 之前应为 '='、','、';'、'asm' 或 'attribute' 'BIT_STRING_encode_xer' ../src/BIT_STRING.c:141:错误:预期')' 在“”令牌之前:* [src/BIT_STRING.o] 错误 1

在 eclipce 中我只是在 src 文件夹中添加了生成的类并添加了标题。

【问题讨论】:

  • 您需要提供更多信息,例如您正在编译的内容的最小示例或中间 C 代码。

标签: c asn.1


【解决方案1】:

编译器错误看起来很神秘,但它们是为人类阅读而设计的。通常,您看到的第一个错误是问题的最佳指示(假设只有一个)。

in file included from asn_application.h:45, from client.c:10: constr_TYPE.h:15:28: error: ber_tlv_length.h: No such file or directory

所以编译器的搜索路径中没有标头ber_tlv_length.h。看起来这是应该包含在 lionet.info 代码中的标题之一。所以找出这些头文件的位置,或者将它们移动到您知道编译器已经在搜索头文件的位置,或者告诉编译器查看它们的位置 (-I/path/to/headers/)。

【讨论】:

    猜你喜欢
    • 2013-06-20
    • 2021-11-05
    • 2019-08-12
    • 2022-01-17
    • 2015-01-26
    • 2020-09-05
    • 1970-01-01
    • 2011-05-01
    • 1970-01-01
    相关资源
    最近更新 更多