You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用asn1c编译ETSI的VAM-PDU-Descriptions.asn时遇WITH语法错误求助

ASN.1编译报错:unexpected TOK_WITH, expecting ';'

使用命令asn1c VAM-PDU-Descriptions.asn编译ETSI官方提供的VAM-PDU-Descriptions.asn文件时,触发如下语法错误:

ASN.1 grammar parse error near VAM-PDU-Descriptions.asn:21 (token "WITH"): syntax error, unexpected TOK_WITH, expecting ';'
Cannot parse "VAM-PDU-Descriptions.asn"

出错的ASN.1代码片段如下(重点为第21-22行的WITH SUCCESSORS):

VAM-PDU-Descriptions {itu-t(0) identified-organization(4) etsi(0) itsDomain(5)
    wg1(1) 103300 vam(1) major-version-3(3) minor-version-1(1)}
DEFINITIONS AUTOMATIC TAGS ::=
BEGIN

    IMPORTS
    AccelerationChangeIndication, BasicContainer, CartesianAngle, ClusterBreakupInfo,
    ClusterJoinInfo, ClusterLeaveInfo, Curvature, CurvatureCalculationMode, 
    DeltaTimeQuarterSecond, GenerationDeltaTime, HeadingChangeIndication, ItsPduHeader, LanePosition, 
    LateralAcceleration, LongitudinalAcceleration, PathHistory, PathPredicted, 
    SequenceOfSafeDistanceIndication, SequenceOfTrajectoryInterceptionIndication, 
    SequenceOfTrajectoryInterceptionIndication, Speed, StabilityChangeIndication, StationId, 
    TrajectoryInterceptionIndication, VerticalAcceleration, VruClusterInformation, VruDeviceUsage, 
    VruEnvironment, VruExteriorLights, GeneralizedLanePosition, VruProfileAndSubprofile, VruMovementControl,  
    VruSizeClass, YawRate, Wgs84Angle
    FROM ETSI-ITS-CDD {itu-t (0) identified-organization (4) etsi (0) itsDomain (5) wg1 (1) 102894 cdd (2) major-version-3 (3) minor-version-1 (1) }
    WITH SUCCESSORS
    ;

    VAM ::= SEQUENCE {
        header ItsPduHeaderVam,
        vam    VruAwareness
    }

问题原因

WITH SUCCESSORS是ETSI在ASN.1中使用的扩展语法,用于表示导入的类型兼容后续版本的定义,但asn1c默认不支持该语法,因此编译时触发错误。

解决方法

  • 方法一:启用asn1c的扩展支持
    编译时添加--keep-with-successors参数,命令改为:

    asn1c --keep-with-successors VAM-PDU-Descriptions.asn
    

    该参数会让asn1c保留WITH SUCCESSORS语法并正常编译。

  • 方法二:手动移除扩展语法
    如果不需要兼容后续版本的类型定义,可以直接删除ASN.1文件中WITH SUCCESSORS这一行,注意保留末尾的分号,修改后的IMPORTS块结尾如下:

    FROM ETSI-ITS-CDD {itu-t (0) identified-organization (4) etsi (0) itsDomain (5) wg1 (1) 102894 cdd (2) major-version-3 (3) minor-version-1 (1) }
      ;
    

内容的提问来源于stack exchange,提问作者Alessandro

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 03:55:28