File name conflict in C codes generated by osmocom

2019-02-26 07:20发布

问题:

I have used the osmocom asn1c compiler (the aper-prefix branch), to obtain an implementation of the GSM_MAP and TCAP protocols. Each protocol has been successfully compiled. But during the use of both in one project, the following error is raised:

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),

I suggest that the problem is file names conflicts in C language, because there is same name structure with different definitions in the two different C files (e.g. ErrorCode.h which is used in both protocols)

/* 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_ */

So try to solve the problem, using osmocom PREFIX feature:

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

However, the compiler reports the following syntax error:

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

Is anyone aware of this problem and a possible solution?

标签: c gsm asn.1 asn1