osmocom asn1c为GSM_MAP / TCAP协议生成的C代码中的文件名冲突

时间:2018-12-06 18:03:54

标签: c gsm asn.1 asn1

我已经使用osmocom asn1c compiler(aper-prefix分支)来获得GSM_MAP和TCAP协议的实现。每个协议都已成功编译。但是在一个项目中同时使用两者时,会出现以下错误:

src/tcap/src/ErrorCode.c:35:20: error: ‘union ErrorCode_u’ has no member named ‘nationaler’
  { ATF_NOFLAGS, 0, offsetof(struct ErrorCode, choice.nationaler),
                    ^
src/tcap/src/ErrorCode.c:44:20: error: ‘union ErrorCode_u’ has no member named ‘privateer’
  { ATF_NOFLAGS, 0, offsetof(struct ErrorCode, choice.privateer),

我建议问题在于C语言中的文件名冲突,因为在两个不同的C文件(例如,两种协议中都使用的ErrorCode.h)中,具有相同的名称结构和不同的定义

/* ErrorCode structure which is defined in GSM_MAP protocol*/
#ifndef _ErrorCode_H_
#define _ErrorCode_H_
......
typedef struct ErrorCode {
    ErrorCode_PR present;
    union ErrorCode_u {
        long     localValue;
        OBJECT_IDENTIFIER_t  globalValue;
    } choice;

    /* Context for parsing across buffer boundaries */
    asn_struct_ctx_t _asn_ctx;
} ErrorCode_t;
.....
#endif  /* _ErrorCode_H_ */


/* ErrorCode structure which is defined in TCAP protocol*/
#ifndef _ErrorCode_H_
#define _ErrorCode_H_
.......
typedef struct ErrorCode {
    ErrorCode_PR present;
    union ErrorCode_u {
        long     nationaler;
        long     privateer;
    } choice;

    /* Context for parsing across buffer boundaries */
    asn_struct_ctx_t _asn_ctx;
} ErrorCode_t;
......
#endif  /* _ErrorCode_H_ */

因此,请尝试使用 osmocom PREFIX 功能解决问题:

ASN1C_PREFIX="TCAP_" asn1c -fcompound-names DialoguePDUs.asn tcap.asn UnidialoguePDUs.asn

但是,编译器报告以下语法错误:

FATAL: Cannot dereference dialogueRequest at line 13
FATAL: Cannot compile "TCAP_DialoguePDU" (21:1) at line 13
FATAL: Cannot compile "TCAP_DialoguePDU" (21:1) at line 13

有人知道这个问题和可能的解决方案吗?

0 个答案:

没有答案