libtasn1 compile issue in ANS1.c
Simon Josefsson
simon at josefsson.org
Tue May 26 11:11:33 CEST 2009
Nikos Mavrogiannopoulos <nmav at gnutls.org> writes:
> Didier Godefroy wrote:
>
>>>> libtool: compile: cc -DHAVE_CONFIG_H -I. -I.. -I./gllib -DASN1_BUILDING
>>>> -pthread -I/usr/local/include -O4 -g3 -w -c -MD ASN1.c -DPIC -o
>>>> .libs/ASN1.o
>>>> cc: Error: ASN1.c, line 153: Invalid enumerator. (badenum)
>>>> TRUE = 277,
>>>> -----^
>>>> cc: Error: ASN1.c, line 154: Invalid enumerator. (badenum)
>>>> FALSE = 278,
>>>> -----^
>>>>
>>>> They look to me to be the same as all the others, but only TRUE and FALSE
>>>> are causing the error.
>>>> I haven't found any hints on possible fixes and the latest daily snapshot
>>>> doesn't fix that either.
>>> maybe TRUE and FALSE are reserved in this compiler. If you replace them
>>> with ASN1_TRUE and ASN1_FALSE the compiler complains?
>> That did it!!!
>> It didn't complain, built all the way and all 5 tests passed.
>> One more porting issue fixed.
>
> I just noticed that this enumeration is auto-generated with bison from
> the given grammar's tokens, thus TRUE/FALSE cannot be replaced. However
> would adding #undef TRUE and #undef FALSE solve the compilation issue
> for you?
We can change the bison source, can't we? Like this:
/Simon
diff --git a/lib/ASN1.y b/lib/ASN1.y
index b335cbc..14e2eb6 100644
--- a/lib/ASN1.y
+++ b/lib/ASN1.y
@@ -85,8 +85,8 @@ static int _asn1_yylex(void);
%token OBJECT
%token STR_IDENTIFIER
%token BOOLEAN
-%token TRUE
-%token FALSE
+%token ASN1_TRUE
+%token ASN1_FALSE
%token TOKEN_NULL
%token ANY
%token DEFINED
@@ -195,8 +195,8 @@ tag : tag_type {$$=$1;}
default : DEFAULT pos_neg_identifier {$$=_asn1_add_node(TYPE_DEFAULT);
_asn1_set_value($$,$2,strlen($2)+1);}
- | DEFAULT TRUE {$$=_asn1_add_node(TYPE_DEFAULT|CONST_TRUE);}
- | DEFAULT FALSE {$$=_asn1_add_node(TYPE_DEFAULT|CONST_FALSE);}
+ | DEFAULT ASN1_TRUE {$$=_asn1_add_node(TYPE_DEFAULT|CONST_TRUE);}
+ | DEFAULT ASN1_FALSE {$$=_asn1_add_node(TYPE_DEFAULT|CONST_FALSE);}
;
@@ -415,7 +415,7 @@ static const int key_word_token[] = {
ASSIG,OPTIONAL,INTEGER,SIZE,OCTET,STRING
,SEQUENCE,BIT,UNIVERSAL,PRIVATE,OPTIONAL
,DEFAULT,CHOICE,OF,OBJECT,STR_IDENTIFIER
- ,BOOLEAN,TRUE,FALSE,APPLICATION,ANY,DEFINED
+ ,BOOLEAN,ASN1_TRUE,ASN1_FALSE,APPLICATION,ANY,DEFINED
,SET,BY,EXPLICIT,IMPLICIT,DEFINITIONS,TAGS
,BEGIN,END,UTCTime,GeneralizedTime
,GeneralString,FROM,IMPORTS,TOKEN_NULL,ENUMERATED};
More information about the Gnutls-devel
mailing list