ada

Access c constant from Ada

偶尔善良 提交于 2019-12-10 15:22:53
问题 I have a header file with a type definition like this #ifndef SETSIZE #define SETSIZE 32 #endif typedef struct _set { unsigned array[SETSIZE]; } set_t; To use a corresponding C-function I need to have the set_t type available in Ada. The problem is that SETSIZE is a configurable parameter (with default value 32). If I understand it correctly I cannot access preprocessor defines from Ada. Would it be possible to add a constant to the c-file and use this in Ada like this: #ifndef SETSIZE

Creating Incompatible Number Subtypes

萝らか妹 提交于 2019-12-10 11:22:52
问题 In Ada, it is possible to create incompatible equivalent numeric types: type Integer_1 is range 1 .. 10; type Integer_2 is range 1 .. 10; A : Integer_1 := 8; B : Integer_2 := A; -- illegal! This prevents accidental logical errors such as adding a temperature to a distance. Is it possible to do something similar in Java? E.g. class Temperature extends Double {} class Distance extends Double {} Temperature temp = 20.0; Distance distance = temp; // Illegal! EDIT I've discovered an unrelated

Ada: gnat gprbuild How to link in libraries?

两盒软妹~` 提交于 2019-12-10 11:05:50
问题 In this multi-language GPRBuild project I'm working on, I have some c++ library files (*.a) I need to link into my executable. Is there an gpr attribute to tell it what to link in or anyway to pass -l -L switches to the linker? 回答1: Or even better: Project my_library is For externally_built use "true"; For library_dir use "/where/ever"; For library_name use "mylibname"; For source_dirs use (); -- no sources. For library_kind use "static"; -- if it is a static lib .a -- for library_kind use

Passing an Array allocated from a C-routine to Ada

≯℡__Kan透↙ 提交于 2019-12-10 08:21:05
问题 Passing arrays of structures/records from Ada to C routines is one thing. In this case the memory management is done in Ada. But when interfacing with third party libraries there is often the problem that Memory management is done in the C part. For example: For the C-structure: typedef struct _MYREC { int n; char *str; } MYREC; the following C-routine allocates Memory and returns a pointer to a MYREC-array with n elements: MYREC * allocMyrec(int n); Problem is that the returned Pointer does

Get Ada (compiled with GNAT) to import files from outside current directory?

你。 提交于 2019-12-10 02:52:16
问题 I'm doing an intro to programming course at university, and the language of choice is Ada. I'm coding in Kate and compiling with GNAT 4.6.3. We have to use teacher-provided libraries for our programs, like so: with foo; use foo; Of course, then the file foo.adb has to be contained in the same directory as my source file. Since multiple projects depend on this one library, and I like to keep each project in its own subdirectory, I have to copy the library files into each new project. Not to

Does Ada real-time need an underlying operating system?

江枫思渺然 提交于 2019-12-09 16:49:45
问题 From what I have understood by reading the documentation, the Ada real-time module works completely isolated from the OS. It's possible to have concurrency without having an underlying OS and a resource manager. Ada handles task dispatching, time management, task state transition, list managements, task priority, locking policies, scheduling policies, ISR, inter task communication, etc. If so then Ada real-time module is kind of a real-time operating system? 回答1: Both yes and no. What an Ada

How to create an ada lib.a and link to C

主宰稳场 提交于 2019-12-09 12:33:28
问题 I am trying to create an ada library and have tried a few different things. I have tried compiling the project using makefiles and trying to create a library from all the .o files This seemed to not work as expected. I then asked adacore support and they pointed me in the direction of using .gpr files for both the ada and c projects and withing in the ada.gpr that should create a library. This almost worked but when it tries to compile the ada I get undefined references. What I have tried:

Setting the license for modules in the linux kernel

半城伤御伤魂 提交于 2019-12-08 21:14:23
问题 I've written some kernel modules in Ada, and I've hit a bit of a problem. License is defined as a c macro, and I can't work out what it actually is. Is it a suitable solution to simply have some c re-exporting all the c functions which require GPL if both the c and the ada module have GPL compatible licenses? Is there a better way to do this? 回答1: Dealing with C macros is a royal PITA. I have a dream that one day C programmers will do the rest of the world a favor and quit using them. If it

Command line arguments for Ada

六眼飞鱼酱① 提交于 2019-12-08 19:38:14
问题 I'm writing an Ada program that is supposed to do case conversion for alphabetic characters. The program uses 1, 2 or 3 command line arguments. I pretty much have the thing written up, but I have no clue as to how to how to do arguments. the command line arguments are to: A single character specifying whether uppercase conversion or lowercase conversion is to be applied to the input. 'U' or 'u' signifies uppercase conversion; 'L' or 'l' specifies lowercase conversion. This parameter is

How to I build a string from other strings in Ada?

烈酒焚心 提交于 2019-12-08 19:23:26
问题 I want to output a header line in a log file and then a line of '-' before the data. To do this I create a string of the header and then outpout the same number of '-'. But the below code always fails with a CONSTRAINT_ERROR because the generated string is not 1024 characters. In Ada string assignments require exactly the same length not just sufficient capacity. Option 1) is to compute the exact length but that is brittle to future changes. Option 2) is to use something other than String.