0
votes

I am debugging some simulation software that has been written in two parts- one part using C++, and the other using Ada. On the GUI, there are a few variables displaying information about an entity as it moves from point A to point B, such as the Time To Go (time it will take to complete that leg of the journey given its current speed & any other factors, such as wind) and ETA. One of these values is incorrect.

It seems that the value displayed is coming from part of the Ada code:

--update the legETAValid attribute
this.steeringData.legETAValid := newSteeringData.legTTGValid;

I noticed on the above line, that an incorrect value is being passed to the variable that is being displayed on the GUI, so I changed the line to the vale that should be displayed:

this.steeringData.legETAValid := newSteeringData.legETAValid;

However, when I try to build and run this code, I get a compile error that says: "no selector "legETAValid" for type "SteeringData_record" defined at...."

Having never used Ada before, I'm unsure what this compile error means... is it similar to an "undeclared identifier" in C/C++? I have tried doing a 'Find all references' on the variable, and there are other places in the project where it is being used, so I wouldn't have thought that it is an 'undeclared identifier'... What does this error mean?

Edit 04/02/2015 @ 09:10

The variable is declared in a .ads file with the line:

 legETAValid : Boolean := false;
1
It may be declared, but not "visible". You need to "with" the (usually) package that declares it, and either "use" that package, or "use type" to make that type's operations visible, or fully qualify its name, as in C++ namespaces. How do the "other places" make it visible? Adding relevant declarations to the question may help get an answer. - user_1818839
What that should mean is that if you look at type “SteeringData_record" defined at ... there won’t be a component legETAValid. I don’t know a lot about the subject, but it seems at least possible that the ETA to be displayed would - provided that the TTG is valid - be found by adding the TTG to the current time. In any case, why would a flag that the ETA is valid affect the ETA that is displayed? It might affect whether the ETA is displayed at all. So the original code may well be correct as far as the validity is concerned. - Simon Wright
@BrianDrummond use wouldn't be a factor in this case. It only affects what identifiers would be directly visible, i.e. without following a period. - ajb
Since legETAValid must be a record component and not a function (since you've got it on the left side of :=), the only reason I can think of why the selector might be legal in some places and not others is that the record type is private (type T is private), or is a private extension (type T is new T2 with private). In that case, the component would be visible in the package where the record is declared (after the declaration), and in parts of packages that are children of that package. It won't be visible anywhere else, because it's private. - ajb
@ajb, are we sure that the type of this.steeringData on the left is the same as the type of newSteeringData on the right? - Simon Wright

1 Answers

2
votes

no selector "legETAValid" for type "SteeringData_record" defined at.... tells us that:

  • SteeringData_record is a type, which:
    • The type doesn't have a visible component named legETAValid.
    • The type isn't a tagged record with a primitive function named legETAValid.

"Selector" is a general term describing the second identifier when using dot notation (Name.Selector). What it actually is depends on the context. It could also have been the case that newSteeringData was a package and legTTGValid was a function or object declared in the public part of the package specification.

A suggestion: It takes two weeks to learn Ada. Consider spending the time to learn it. If you know C++, try Ada Distilled.