Ada code snippets

Mmm... 🤷🏻‍♂️ Try to add it into your gpr, something like with "matreshka/league.gpr;" at the first line.

Discussion

Change matreshka/league.gpr to the path of the matreshka library you need.

Discussion

Ahh, you have to use alr run for compiling and running. And works like the Python's virtualenv.

Discussion

So no need of a gpr, because alr already do it for you when you call alr init. Well, I may tray compiling it later.

Discussion

Try this

GNATCOLL.JSON.Create (Integer'(10))

Discussion

Finally! Found the problem of Alr compilation *in Manjaro*: a C file tries to include unistd.h which in turn it tries to include stddef.h header. Well, the header exists, but it is in /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.1/include/ (for GCC version 8.2.1 for 64bit arch.).

Adding this path to the CPATH env variable solve the problem.

mosteo, if some Manjaro users tells you that cann't compile because of "missing stddef.h" header. Here's the solution 👆

Discussion

Hi, I try to use alr to install OpenGLAda, glut, and other libraries. It respond in this way:

$ ~/Ada/bin/alr -d show glut
[...]
-->> Found unsupported distro: ManjaroLinux

raised PROGRAM_ERROR : Unsupported package manager
[~/.config/alire/alr/bin/alr]
Alr.Origins.New_Origin at alr-origins.adb:45
Alr.Commands.Show.Report at alr-commands-show.adb:47
Alr.Commands.Show.Execute at alr-commands-show.adb:128
Alr.Commands.Execute_By_Name at alr-commands.adb:555
Alr.Commands.Execute at alr-commands.adb:533
Alr.Main at alr-main.adb:24
Main at b__alr-main.adb:1646
[/usr/lib/libc.so.6]
0x7ff49ef6c221
[~/.config/alire/alr/bin/alr]
0x562b83d8c0bc _start at ???
0xfffffffffffffffe

Discussion

You can reproduce it by this simple C code:
```

#include <stdio.h>

int main() {
setvbuf(stdout, nullptr, _IONBF, 0);
setvbuf(stdout, nullptr, _IOFBF, 4096);
fwrite("hello",5,1,stdout);
fwrite("world",5,1,stdout);
return 0;
}

```
strace it and I'll see some strange behavior.

Discussion

write(1, "hello", 5hello)                    = 5
write(1, "w", 1w) = 1
write(1, "orld", 4orld) = 4

Discussion

If we comment second setvbuf call:

int main() {
setvbuf(stdout, nullptr, _IONBF, 0);
//setvbuf(stdout, nullptr, _IOFBF, 4096);
fwrite("hello",5,1,stdout);
fwrite("world",5,1,stdout);
return 0;
}


then write will be called only twice:
write(1, "hello", 5hello)                    = 5
write(1, "world", 5world) = 5

Discussion

Yes, I know. However, I think that for some reason, the make setup is not working because it tries to compile zlib no matter the value of the configuration.

Discussion

Just put function into package with pragma Pure; and compiler will ensure that function has no side effect

Discussion

Maybe some overview of tools provided by gnat? Like what for gprbuild gnatcheck gnatstub gnatpp, etc are

Discussion

You can also try -argc -c options. That will force gprbuild to pass -s to compiler

Discussion

int x
syntax is a pure Algol-60 syntax 🙂
integer p, q;
y := 0; i := k := 1;

Discussion

Like out by copy parameters, indefinite return values, access to nested functions, dispatching calls on interfaces and so on

Discussion

I'm using

pragma Source_File_Name
to put package spec and body together to the same source file.

https://godbolt.org/z/e1W70i

Why does it say: "example.adb:8:01: end of file expected, file can have only one compilation unit"?

Discussion

Ok. What is the usecase for

pragma Source_File_Name
in GNAT reality?

Discussion

So,

Index
parameter is not usable for gnat?

Discussion

Without External compiler eliminate F :(

Discussion

Convention => Ada is default, could be omitted

Discussion

Right, user shouldn't read after private keywork 😊

Discussion

Well, yes. But I usually do with "matreshka_league.gpr"; and provide ADA_PROJECT_PATH or GPR_PROJECT_PATH enviroment variable to avoid full paths in project file

Discussion