illegal operand for numeric conversion

23
Feb

There are many different types of conversions in Ada.

The simplest is from a subtype to another subtype in the same type. These can use the assignment operator as is:

1
 

Then you have conversion from one scalar type to another. This is done using the type as a function (which it is):

1
 

Finally, you have to often convert the scalar value from an enumeration. That is done using the 'pos and 'val attributes.

1
 

Now, if you read the Ada documentation a little too much, you probably heard of the qualified operator. This is used when values are named the same but are from different types (generally a names from different enumerations, but that's also true for function names, etc.)

In this case you can have two solutions:

1
 

In the first case, it is a qualification. In the second case, it's selection. Either way, you define the exact type of a name which would otherwise be ambiguous.

If none of these work for you, you probably have an object (a record) which cannot be assigned this easily.

0
Your rating: None