开发者

In Ada how do I initialise an array constant with a repeated number?

开发者 https://www.devze.com 2022-12-25 04:55 出处:网络
I need an array of 820 zeros for using with a mathematical function. In C I could just write the following and the compiler would fill the array:

I need an array of 820 zeros for using with a mathematical function.

In C I could just write the following and the compiler would fill the array:

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

However in Ada that isn't possible. I really don't want to hard code the 820 elements as 0.0. Is开发者_运维百科 there a way to get the compiler to do it?

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

Using Ada 95 and GNAT.


Use an aggregate:

Empty_Number_A : constant Number_A := (others => 0.0);
0

精彩评论

暂无评论...
验证码 换一张
取 消