In Ada, how to initialize an array constant with a repeated number?

I need an array of 820 zeros to use with a math function.

In C, I could just write the following, and the compiler populated the array:

 const float EMPTY_NUMBER_A[820] = { 0.0, };

However, in Hell this is not possible. I really don't want to hardcode 820 elements as 0.0. Is there a way to get the compiler to do this?

 type Number_A is array (1 .. 820) of Float;
 EMPTY_NUMBER_A : constant Number_A := ???;

Using Ada 95 and GNAT.

+3
source share
1 answer

Use aggregate :

Empty_Number_A : constant Number_A := (others => 0.0);
+9
source

Source: https://habr.com/ru/post/1739065/


All Articles