The problem is that you're compiling with a C-compiler.... so struct's must be referred with a full struct Name
(or by the typedef'ed name if you have done so... as the generated code does).
I pasted your ASN.1 module using the URL you provided, downloaded the generated code and tried to use it.
Note that the generated definition contains (in M1.h)
#ifdef __cplusplus
extern "C" {
#endif
/* M1 */
typedef struct M1 {
long number;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} M1_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_M1;
#ifdef __cplusplus
}
#endif
Now I tried with mymain.C
#include "M1.h"
int main() {
M1 a;
struct M1 b;
M1_t c;
}
compiling with g++ (i.e. as a C++ program), there's no complain
Now if I compile (same source) mymain.c with gcc, then I get:
x.c: In function ‘main’:
x.c:6:4: error: unknown type name ‘M1’
M1 a;
Removing that line (i.e. not using M1, but using either struct M1
or M1_t
to refer to the type), everything compiles fine.
In summary:
- Choose your poison, either C or C++
- If you're in C++, use
M1
or M1_t
(or struct M1
)
- If you're in C, use
struct M1
or M1_t
For all the in and outs check: