1
votes

Cross-posting, no answer on comp.lang.ada.

I am trying to generate Ada bindings for the GSL (Gnu Scientific Library) odeiv2 package (ordinary differential equations). So I do the following 2 steps:

  1. Go to an empty directory "src" and execute

    g++ -c -fdump-ada-spec -C /usr/include/gsl/gsl_odeiv2.h

  2. Go to an empty directory "obj" and execute

    gcc -c -gnat05 ../src/*.ads

Unfortunately, gsl_odeiv2.h includes stdio.h, and this leads to a series of errors like

stdio_h.ads:117:69: "FILE" not declared in "x86_64_linux_gnu_bits_types_FILE_h"

Strangely, FILE is declared, I found it in /usr/include/x86_64-linux-gnu/bits/types/FILE.h, which is included in stdio.h.

I guess that I don't even need FILE for my odeiv2 application. So has anyone a hint how to get rid of this error?

2
-fdump-ada-spec has to deal with the C include file mess somehow, and it does that by generating bindings for the transitive closure of the header files you request and anything they include. There is also -fdump-ada-spec-slim (or -fdump-ada-slim-spec, I forget) which only binds the specific headers you ask for. I tend to use this, and explicitly add any further headers I need to fix missing bindings. - user_1818839
Thanks Brian, seems promising. Not yet at the end, but on the way. Thanks. - hreba

2 Answers

0
votes

The top-secret GNAT documentation says,

GNAT includes a binding generator for C and C++ headers which is intended to do 95% of the tedious work of generating Ada specs from C or C++ header files.

Note that this capability is not intended to generate 100% correct Ada specs, and will is some cases require manual adjustments, although it can often be used out of the box in practice.

Thus you should expect to have to make manual adjustments to the generated bindings if they don't work as generated.

0
votes

The problem appeared again with other C files, but this time I found the solution on the web. From Interfaces.C_Streams:

  subtype FILEs is System.Address;
  -- Corresponds to the C type FILE*