ada

Is it possible to declare Ada range with unlimited upper bound?

不想你离开。 提交于 2020-02-03 10:13:16
问题 I would like to declare a speed range for a record type in Ada. The following won't work, but is there a way to make it work? --Speed in knots, range 0 to unlimited Speed : float Range 0.0 .. unlimited ; I just want a zero positive value for this number... 回答1: You can't -- but since Speed is of type Float , its value can't exceed Float'Last anyway. Speed : Float range 0.0 .. Float'Last; (You'll likely want to declare an explicit type or subtype.) 回答2: Just for completeness, you can also

Is it possible to declare Ada range with unlimited upper bound?

☆樱花仙子☆ 提交于 2020-02-03 10:13:10
问题 I would like to declare a speed range for a record type in Ada. The following won't work, but is there a way to make it work? --Speed in knots, range 0 to unlimited Speed : float Range 0.0 .. unlimited ; I just want a zero positive value for this number... 回答1: You can't -- but since Speed is of type Float , its value can't exceed Float'Last anyway. Speed : Float range 0.0 .. Float'Last; (You'll likely want to declare an explicit type or subtype.) 回答2: Just for completeness, you can also

Freeing a string (allocated in Ada) in a C function using free()

我怕爱的太早我们不能终老 提交于 2020-02-03 09:03:33
问题 I am working on a C-Ada binding application, where I am allocating a new string in Ada side using Interfaces.C.Strings.New_String() . Interfaces.C.Strings already has a procedure Free() to deallocate the memory for string. Since I need to pass this string to a C function using Interfaces.C.Strings.Chars_Ptr : Is it OK if I deallocate memory for the string in C side using the free() function (declared in stdlib.h)? Is it safe if I free the memory from C side? Or I should better free it using

Is there a way to format text output in Ada

一个人想着一个人 提交于 2020-02-03 04:49:06
问题 Is there a way to format the string being outputted? I'm trying get a pretty view of the following output 1: Ashley | 01033438392 | Wellington, New Zealand | 1987- 4-14 2: Aloha | 01087651234 | Hawaii, United States of America | 1988- 9-23 3: Jack | 01082840184 | Beijing, China | 1989- 6-19 If I was programming in C, I would do something like printf("%10s | %11s | %20s | %4d-%2d-%2d\n",name,phone,address,year,month,day); Would it be possible to do this kind of formatting in Ada 05? PS Please

Example code detailing difference in typing between Ada and Java [closed]

人走茶凉 提交于 2020-01-29 23:30:28
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . I'm trying to think of a good example detailing the difference between Ada's strict typing and Java's strong typing. Does anyone have a good example for identifying these differences in type conversion using integer based values? 回答1: This may prove helpful, from the Ada

ADA not able to link glut32.dll in GPS IDE

允我心安 提交于 2020-01-25 04:40:49
问题 I'm writing simple OpenGl program using ADA in GPS IDE. I have all supporting file (like glut.ads/adb, Gl.ads/adb) I have created Pragma like "pragma Linker_Options("../Lib/glut32.dll");" But I get errors like Link [link] main.adb collect2.exe: error: ld returned 5 exit status gprbuild: link of main.adb failed gprbuild: failed command was: c:\gnat\2019\bin\gcc.exe main.o b__main.o D:\Saravanan\Project\Training\Open_GL Project\obj\GL-Extended.o D:\Saravanan\Project\Training\Open_GL Project\obj

Concat separated fields in one

倖福魔咒の 提交于 2020-01-24 14:54:24
问题 I'm working in Ada, I have a very ugly type that I can't modify and I want to do something easy to use. The type is something like this : for T_Ugly_Type'Alignment use 4; for T_Ugly_Type'Size use 48; for T_Ugly_Type use record Value_Bits_00_07 at 16#00# range 0 .. 7; -- 8 bits Field1 at 16#00# range 8 .. 15; -- 8 bits Field2 at 16#02# range 0 .. 11; -- 12 bits Value_Bits_08_11 at 16#02# range 12 .. 15; -- 4 bits Value_Bits_12_15 at 16#03# range 0 .. 3; -- 4 bits Field3 at 16#03# range 4 .. 15

Passing structure from C to Ada

霸气de小男生 提交于 2020-01-23 18:19:25
问题 I need to pass a structure from C to Ada in an Ada binding application. Thus, I have declared the structure in both Ada and C so that both the source sides can decipher the structure composition. In C, typedef struct { int Status_Code; int Error_Code; } Edit_Result_Type; In Ada, type Edit_Result_Rec_Type is record Status : Integer; Error_Code : Integer; end record; pragma Convention (Convention => C, Entity => Edit_Result_Rec_Type); for Edit_Result_Rec_Type use record Status at 0 range 0 ..

Passing structure from C to Ada

心不动则不痛 提交于 2020-01-23 18:17:12
问题 I need to pass a structure from C to Ada in an Ada binding application. Thus, I have declared the structure in both Ada and C so that both the source sides can decipher the structure composition. In C, typedef struct { int Status_Code; int Error_Code; } Edit_Result_Type; In Ada, type Edit_Result_Rec_Type is record Status : Integer; Error_Code : Integer; end record; pragma Convention (Convention => C, Entity => Edit_Result_Rec_Type); for Edit_Result_Rec_Type use record Status at 0 range 0 ..

Use Ada code in Android

▼魔方 西西 提交于 2020-01-23 06:28:23
问题 Is there any possibility to use old Ada code in Android? I have an old script written in Ada and it would be great if I could just use that code in Android directly (via NDK or JNI etc). Is this possible? Or should I rather port the code? Here are some links I found but I don't really understand in what extend they answer my question: http://en.wikibooks.org/wiki/Ada_Programming/Platform/VM/Java http://code.google.com/p/javada/ http://code.google.com/p/jgnat/ http://en.wikipedia.org/wiki/GNAT