How can someone define a data type, and then use it in other file that's included in the same file, right after the data type definition

StackOverflow https://stackoverflow.com/questions/5039780

Question

I needed asn1 BER encoder/decoder and found it as a part of "asn1c" compiler (here's the link http://lionet.info/asn1c/blog/).

I have no problems compiling the whole thing, using "configure, make, make install" procedure, but it seems impossible to compile it separately.

I'm trying to compile BER encoder/decoder functionality of this package into a static library, in NetBeans. However, I'm having big problems with some "include" nonsenses. Here's an example...

In the asn1parser.h file there's typedef of new type called "asn1c_integer_t"

//some preprocessor statements removed to keep this post short...
typedef intmax_t asn1c_integer_t;


#include "asn1p_list.h"
#include "asn1p_oid.h"      /* Object identifiers (OIDs) */
#include "asn1p_ref.h"      /* References to custom types */
etc...

However, some of these files that are included in the previous file (asn1p_oid.h, for example) are using the new data type defined in the previous file.

#ifndef ASN1_PARSER_OID_H
#define ASN1_PARSER_OID_H

typedef struct asn1p_oid_arc_s {
    asn1c_integer_t number; /* -1 if not yet defined */
    char *name; /* 0 if not defined */
} asn1p_oid_arc_t;
etc...

It makes no sense to me, and I keep getting errors like:

asn1parser.h:32: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘asn1c_integer_t’

Can anyone help me to solve this issue?

Was it helpful?

Solution 2

I was sure that "includes" were the cause of the trouble, however, the problem was this line

typedef intmax_t asn1c_integer_t;

Apparently my version of gcc does not recognize this intmax_t type. I exchanged it for simple "int", and now it works :D

OTHER TIPS

Have you tried #include "asn1parser.h" in "some of these files"? Maybe they are also included form elsewhere, and at that point, the name asn1c_integer_t is unknown to the compiler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top