问题
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:
Go to an empty directory "src" and execute
g++ -c -fdump-ada-spec -C /usr/include/gsl/gsl_odeiv2.h
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?
回答1:
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.
回答2:
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*
来源:https://stackoverflow.com/questions/61121922/fdump-ada-spec-file-not-declared