Closed dmccoystephenson closed 2 months ago
Thank you for reporting this, and providing a workaround.
Regarding potential solutions - unless you're willing to implement it and submit a PR, I have neither time nor sufficient competence to muck with the ASN.1 compiler to the degree necessary.
So, closing this issue as unlikely to be fixed by me. If/when you implement one of your potential solutions - your PR would be welcome here.
Thanks for the reply! I have opened this issue on a separate fork.
Would you mind posting here the link to the issue you opened?
Would you mind posting here the link to the issue you opened?
Here you go! https://github.com/usdot-fhwa-stol/usdot-asn1c/issues/1
Hey @dmccoystephenson, you can try compiling with the -fno-include-deps
flag.
While it isn't the optimal solution, it may solve your issue.
Hey @dmccoystephenson, you can try compiling with the
-fno-include-deps
flag. While it isn't the optimal solution, it may solve your issue.
Hey @v0-e, I appreciate the response! I did some preliminary testing using the -fno-include-deps
flag and this does appear to solve the compilation issue that occurs when compiling the converter-example program.
Further testing will be necessary to ensure the asn1_codec project still functions as expected when utilizing this argument, but this is very promising!
Problem
A circular reference of header imports is present in the C code generated from the ASN.1 Compiler. The generated file (Header A) depends on a structure defined in another header file (Header B), which indirectly depends on Header A.
Current Workaround
This can be worked around by inserting a declaration of the structure defined in Header B before it is used, and moving the
include
statement for Header B such that it is after the usage of the structure.Context
The NodeOffsetPointXY structure is part of the J2735 2020 specification. The ASN files can be downloaded from the SaE website.
Potential Solutions
Some potential solutions that do not require the developer/user to modify the generated header directly include the following:
Relevant Error Message
Attempting to build the converter-example program resulted in an error with the NodeOffsetPointXY header class:
This is due to attempting to use a structure prior to its declaration. After overriding the header file with a modified version, the converter-example program was compiled with no issues.
Summary
To summarize, NodeOffsetPointXY.h includes RegionalExtension.h, which imports MapData-addGrpC.h, which imports SignalHeadLocationList.h, which attempts to reference NodeOffsetPointXY_t (defined in NodeOffsetPointXY.h). The ‘NodeOffsetPointXY.h’ header file indirectly attempts to include itself.
Diagram
The following diagram depicts the circular reference: