mouse07410 / asn1c

The ASN.1 Compiler
http://lionet.info/asn1c/
BSD 2-Clause "Simplified" License
98 stars 71 forks source link

object instance with NULL type does not produce valid C structure #55

Closed loblik closed 4 years ago

loblik commented 5 years ago

I have an ASN which basically do something like this.

`ModuleTestClassSimple { iso org(3) dod(6) internet(1) private(4) enterprise(1) spelio(9363) software(1) asn1c(5) test(1) 34 } DEFINITIONS IMPLICIT TAGS ::= BEGIN

MY-TYPE ::= CLASS { &Type } WITH SYNTAX { TYPE &Type}

Node ::= SEQUENCE { type MY-TYPE.&Type({DefTypes}) }

DefTypes MY-TYPE ::= {{ TYPE NULL }}

END `

This translates to union member named NULL of type NULL_t. This will not compile as NULL is defined usually as void*.

velichkov commented 5 years ago

Hi @loblik,

I have an ASN which basically do something like this.

`ModuleTestClassSimple { iso org(3) dod(6) internet(1) private(4) enterprise(1) spelio(9363) software(1) asn1c(5) test(1) 34 } DEFINITIONS IMPLICIT TAGS ::= BEGIN

MY-TYPE ::= CLASS { &Type } WITH SYNTAX { TYPE &Type}

Node ::= SEQUENCE { type MY-TYPE.&Type({DefTypes}) }

DefTypes MY-TYPE ::= {{ TYPE NULL }}

END `

This translates to union member named NULL of type NULL_t. This will not compile as NULL is defined usually as void*.

Tanks for reporting this. Name collisions are always possible and current asn1c version do not attempt to detect and resolve them.

A workaround solution in your case is to add a new type.

--- test.orig.asn   2019-07-29 18:16:57.971812488 +0300
+++ test.asn    2019-07-29 18:28:12.475995299 +0300
@@ -12,6 +12,8 @@
 type MY-TYPE.&Type({DefTypes})
 }

-DefTypes MY-TYPE ::= {{ TYPE NULL }}
+DefTypes MY-TYPE ::= {{ TYPE NULL-Type }}
+
+NULL-Type ::= NULL

 END
loblik commented 5 years ago

Yes, that's what I already did. I just wanted it to be tracked here. Thanks anyway.

mouse07410 commented 5 years ago

Thanks for the reporting. I don't think we can do anything with this, at least not until the upstream addresses this.

Probably should close this issue...?

mouse07410 commented 4 years ago

Since it's unlikely we would be able to do anything about this problem - closing this issue. When upstream fixes it - we'll merge the fix.

In the meanwhile, a PR that fixes it is always welcome, regardless.