* -fdump-ada-spec
@ 2014-10-06 17:45 Simon Wright
2014-10-07 14:08 ` -fdump-ada-spec Stephen Leake
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Simon Wright @ 2014-10-06 17:45 UTC (permalink / raw)
Does anyone know where this is implemented in the GCC sources?
I'm having trouble with some of the system headers: on Mac OS X, with
all the GNATs and GCCs I have, dumping /usr/include/wchar.h uses
'limited with' in a way that doesn't work, whereas on Debian (wheezy,
gcc-4.7) there's no 'limited with'. Of course, wchar.h is different!
I _think_ that -fdump-ada-spec sees that a particular type (eg FILE) is
always accessed via a pointer, and decides that 'limited with' is OK;
but for some reason this ends up being unacceptable.
The ARM (and AI95-0217) didn't help a lot here. I think the problem is
that the original code is like
typedef struct Blah {
int x;
} FILE;
and the generated code is like
package Stdio is
type Blah is record
X : Integer;
end record;
subtype FILE is Blah;
end Stdio;
limited with Stdio;
package Wchar is
procedure Foo (F : access Stdio.FILE);
end Wchar;
and the 'limited with' magic only works for _types_, so you get the
error '"FILE" not declared in "Stdio"'.
Stdio.FILE should be declared as
type FILE is new Blah;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: -fdump-ada-spec
2014-10-06 17:45 -fdump-ada-spec Simon Wright
@ 2014-10-07 14:08 ` Stephen Leake
2014-10-07 16:05 ` -fdump-ada-spec Simon Wright
2014-10-07 15:12 ` -fdump-ada-spec Markus Schöpflin
2014-10-10 10:06 ` -fdump-ada-spec Simon Wright
2 siblings, 1 reply; 7+ messages in thread
From: Stephen Leake @ 2014-10-07 14:08 UTC (permalink / raw)
Simon Wright <simon@pushface.org> writes:
> Does anyone know where this is implemented in the GCC sources?
I don't; I guess you want to develop a patch?
> <snip>
>
> and the 'limited with' magic only works for _types_, so you get the
> error '"FILE" not declared in "Stdio"'.
>
> Stdio.FILE should be declared as
>
> type FILE is new Blah;
As a workaround, you can maintain a patch for the generated code, and
apply it in your Makefile.
--
-- Stephe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: -fdump-ada-spec
2014-10-07 14:08 ` -fdump-ada-spec Stephen Leake
@ 2014-10-07 16:05 ` Simon Wright
0 siblings, 0 replies; 7+ messages in thread
From: Simon Wright @ 2014-10-07 16:05 UTC (permalink / raw)
Stephen Leake <stephen_leake@stephe-leake.org> writes:
> Simon Wright <simon@pushface.org> writes:
>
>> Does anyone know where this is implemented in the GCC sources?
>
> I don't; I guess you want to develop a patch?
Not really; just to understand it better!
For example, you may have taken the online manual's remark "C++ classes
will be mapped to Ada tagged types" as gospel; it turns out that this
only happens for C++ classes with virtual methods. I think.
>> <snip>
>>
>> and the 'limited with' magic only works for _types_, so you get the
>> error '"FILE" not declared in "Stdio"'.
>>
>> Stdio.FILE should be declared as
>>
>> type FILE is new Blah;
Thinking about it, that doesn't match the 'semantics' of typedef.
> As a workaround, you can maintain a patch for the generated code, and
> apply it in your Makefile.
Actually, an editor script to change 'limited with' to plain 'with'
would sort this one out nicely.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: -fdump-ada-spec
2014-10-06 17:45 -fdump-ada-spec Simon Wright
2014-10-07 14:08 ` -fdump-ada-spec Stephen Leake
@ 2014-10-07 15:12 ` Markus Schöpflin
2014-10-07 16:05 ` -fdump-ada-spec Simon Wright
2014-10-10 10:06 ` -fdump-ada-spec Simon Wright
2 siblings, 1 reply; 7+ messages in thread
From: Markus Schöpflin @ 2014-10-07 15:12 UTC (permalink / raw)
Am 06.10.2014 19:45, schrieb Simon Wright:
> Does anyone know where this is implemented in the GCC sources?
The patch implementing -fdump-ada-spec can be found here:
https://gcc.gnu.org/ml/gcc-patches/2010-04/msg01592.html
The diff should give you a precise idea where to look. :-)
Markus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: -fdump-ada-spec
2014-10-06 17:45 -fdump-ada-spec Simon Wright
2014-10-07 14:08 ` -fdump-ada-spec Stephen Leake
2014-10-07 15:12 ` -fdump-ada-spec Markus Schöpflin
@ 2014-10-10 10:06 ` Simon Wright
2 siblings, 0 replies; 7+ messages in thread
From: Simon Wright @ 2014-10-10 10:06 UTC (permalink / raw)
Simon Wright <simon@pushface.org> writes:
> I'm having trouble with some of the system headers: on Mac OS X, with
> all the GNATs and GCCs I have, dumping /usr/include/wchar.h uses
> 'limited with' in a way that doesn't work, whereas on Debian (wheezy,
> gcc-4.7) there's no 'limited with'. Of course, wchar.h is different!
I'm told that this falls under "this capability is not intended to
generate 100% correct Ada specs".
^ permalink raw reply [flat|nested] 7+ messages in thread
* Newcomers to comp.lang.ada: welcome and how did you end up here ?
@ 2014-10-06 22:42 Simon Clubley
2014-10-07 8:10 ` Gour
0 siblings, 1 reply; 7+ messages in thread
From: Simon Clubley @ 2014-10-06 22:42 UTC (permalink / raw)
In recent weeks/months, there's been an influx of newcomers to
comp.lang.ada.
First, welcome to the world of Ada. I hope you find the language
interesting and useful.
Second, how did you end up here ? :-)
The reason for asking is I'm wondering if there are some new Ada related
activities online which have grabbed the attention of people and made
them interested in learning Ada.
There's historically been a major problem with promoting Ada and I'm
now wondering if someone has succeeded in promoting Ada and we don't
even know about it. :-)
Thanks,
Simon.
--
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980s technology to a 21st century world
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Newcomers to comp.lang.ada: welcome and how did you end up here ?
2014-10-06 22:42 Newcomers to comp.lang.ada: welcome and how did you end up here ? Simon Clubley
@ 2014-10-07 8:10 ` Gour
2014-10-07 10:49 ` Luke A. Guest
0 siblings, 1 reply; 7+ messages in thread
From: Gour @ 2014-10-07 8:10 UTC (permalink / raw)
On Mon, 6 Oct 2014 22:42:13 +0000 (UTC)
Simon Clubley <clubley@remove_me.eisner.decus.org-Earth.UFP> wrote:
> Second, how did you end up here ? :-)
In my case, I was already posting here two years ago after spending some
time in #ada where I got lot of useful and friendly advices.
I was looking for an adeqaute language to do my hobby project -
multi-platform desktop app.
However, due to several reasons I was sidetracked and lured into
evaluating some other languages and, moreover, due to life's
cirumstances, didn't have time to work/plan my project.
Recently I've come in contact with Go after being attracted for some
static site generator written in it, but after some deliberation I
decided that it might be fine for my web needs, but not very suitable
for the desktop project.
The first natural step, after being disappointed with my discoveries
with 'modern' languages was to visit #ada again.
One of the things which re-inspired me to do my project in Ada is that
there are still people believing that it's not required that all our
apps should run within browser and/or written by some JS-related crap.
I've decided that even if GtkAda is the only option for writing GUI app
with Ada, it still looks better than offerings in other languages. (I
must admit that havign wxAda would be even better.)
Let me also mention Gnoga project and David's enthusiasm to bring
GUI development with Ada to application's devolopers without JS bagagge.
Now I'm here, learning Ada on my Debian (Sid) box using FSF GNAT and
hope to stay. ;)
Last but not the least, I'm the one who likes to have and buy books in
paper, so seeing Barnes' PIA-2012 is encouraging.
Sincerely,
Gour
--
A person who is not disturbed by the incessant flow of
desires — that enter like rivers into the ocean, which is
ever being filled but is always still — can alone achieve
peace, and not the man who strives to satisfy such desires.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Newcomers to comp.lang.ada: welcome and how did you end up here ?
2014-10-07 8:10 ` Gour
@ 2014-10-07 10:49 ` Luke A. Guest
2014-10-08 7:23 ` Gour
0 siblings, 1 reply; 7+ messages in thread
From: Luke A. Guest @ 2014-10-07 10:49 UTC (permalink / raw)
Gour <gour@atmarama.net> wrote:
> On Mon, 6 Oct 2014 22:42:13 +0000 (UTC)
> I've decided that even if GtkAda is the only option for writing GUI app
> with Ada, it still looks better than offerings in other languages. (I
> must admit that havign wxAda would be even better.)
Yeah hint taken. It's on the back burner but I do intend to get back to it
after my new site is going.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Newcomers to comp.lang.ada: welcome and how did you end up here ?
2014-10-07 10:49 ` Luke A. Guest
@ 2014-10-08 7:23 ` Gour
2014-10-08 8:35 ` Brian Drummond
0 siblings, 1 reply; 7+ messages in thread
From: Gour @ 2014-10-08 7:23 UTC (permalink / raw)
On Tue, 7 Oct 2014 10:49:10 +0000 (UTC)
Luke A. Guest <laguest@archeia.com> wrote:
> Yeah hint taken. It's on the back burner but I do intend to get back
> to it after my new site is going.
Fine, I hope your site's progress is going well. ;)
Just curious, in general, how much does '-fdump-ada-spec' help when
generating (thin) C++ bindings?
Sincerely,
Gour
--
Whatever action a great man performs, common men follow. And
whatever standards he sets by exemplary acts, all the world pursues.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Newcomers to comp.lang.ada: welcome and how did you end up here ?
2014-10-08 7:23 ` Gour
@ 2014-10-08 8:35 ` Brian Drummond
2014-10-08 9:15 ` Simon Wright
0 siblings, 1 reply; 7+ messages in thread
From: Brian Drummond @ 2014-10-08 8:35 UTC (permalink / raw)
On Wed, 08 Oct 2014 09:23:18 +0200, Gour wrote:
> On Tue, 7 Oct 2014 10:49:10 +0000 (UTC)
> Luke A. Guest <laguest@archeia.com> wrote:
>
>> Yeah hint taken. It's on the back burner but I do intend to get back to
>> it after my new site is going.
>
> Fine, I hope your site's progress is going well. ;)
>
> Just curious, in general, how much does '-fdump-ada-spec' help when
> generating (thin) C++ bindings?
My own gut feel on a couple of projects : it probably does 80-90% of the
work, depending on the C/C++ styles involved.
One hardware interface library in C (to the Aardvark I2C/SPI USB
interface from totalphase.com ) used a lot of macros for defining
constants. These were untranslated, appearing as comments in the Ada
package (apparently because they were untyped numbers).
I copied them into a separate package, "aardvark_constants" alongside
the autogenrcated "aardvark_h", uncommented and declared the half dozen
or so constants I needed, leaving the rest as comments against future use.
It would have been a mistake to do this in the autogenerated file because
you couldn't autogenerate it anew...
On a C++ project several years ago I found it made a poor job of
processing C++ templates - perhaps not surprisingly - and the result
needed about 20% rewritten by hand. This may have improved since, but I
wouldn't be surprised if there are still problems in there.
Incidentally '-fdump-ada-spec-slim' often does a better job rather than
polluting your project with the full transitive closure of the C
namespace... '-fdump-ada-spec' merely reveals how awful the #include
mechanism really can get.
-- Brian
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Newcomers to comp.lang.ada: welcome and how did you end up here ?
2014-10-08 8:35 ` Brian Drummond
@ 2014-10-08 9:15 ` Simon Wright
2014-10-08 19:14 ` -fdump-ada-spec (was: Newcomers to comp.lang.ada: welcome and how did you end up here ?) Ludovic Brenta
0 siblings, 1 reply; 7+ messages in thread
From: Simon Wright @ 2014-10-08 9:15 UTC (permalink / raw)
Brian Drummond <brian3@shapes.demon.co.uk> writes:
> One hardware interface library in C (to the Aardvark I2C/SPI USB
> interface from totalphase.com ) used a lot of macros for defining
> constants. These were untranslated, appearing as comments in the Ada
> package (apparently because they were untyped numbers).
Apparently one should use g++ rather than gcc, because it makes a better
job of it.
GNAT GPL 2014 does translate (some) macros; it doesn't always get it
right, eg
#define M_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */
#define M_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */
#define MAXFLOAT 0x1.fffffep+127f
// have to have _something_ besides the constants or no .ads gets
// generated.
extern float sinf(float);
turns into
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package math_h is
M_SQRT2 : constant := 1.41421356237309504880168872420969808; -- ./math.h:1
M_SQRT1_2 : constant := 8#.707106781186547524400844362104849039#; -- ./math.h:2
MAXFLOAT : constant := 16#1.fffffep+127f#; -- ./math.h:3
function sinf (arg1 : float) return float; -- ./math.h:7
pragma Import (CPP, sinf, "_Z4sinff");
end math_h;
And I should have written
extern "C" {
extern float sinf(float);
}
which would have produced
function sinf (arg1 : float) return float; -- math.h:8
pragma Import (C, sinf, "sinf");
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: -fdump-ada-spec (was: Newcomers to comp.lang.ada: welcome and how did you end up here ?)
2014-10-08 9:15 ` Simon Wright
@ 2014-10-08 19:14 ` Ludovic Brenta
2014-10-08 19:48 ` -fdump-ada-spec Simon Wright
0 siblings, 1 reply; 7+ messages in thread
From: Ludovic Brenta @ 2014-10-08 19:14 UTC (permalink / raw)
> Apparently one should use g++ rather than gcc, because it makes a better
> job of it.
>
> GNAT GPL 2014 does translate (some) macros; it doesn't always get it
> right, eg
>
> #define M_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */
> #define M_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */
> #define MAXFLOAT 0x1.fffffep+127f
>
> // have to have _something_ besides the constants or no .ads gets
> // generated.
> extern float sinf(float);
>
> turns into
>
> pragma Ada_2005;
> pragma Style_Checks (Off);
>
> with Interfaces.C; use Interfaces.C;
>
> package math_h is
>
>
> M_SQRT2 : constant := 1.41421356237309504880168872420969808; -- ./math.h:1
> M_SQRT1_2 : constant := 8#.707106781186547524400844362104849039#; -- ./math.h:2
^^ ^
Isn't that a blatant bug? Either in the Ada or in the C source?
--
Ludovic Brenta.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: -fdump-ada-spec
2014-10-08 19:14 ` -fdump-ada-spec (was: Newcomers to comp.lang.ada: welcome and how did you end up here ?) Ludovic Brenta
@ 2014-10-08 19:48 ` Simon Wright
0 siblings, 0 replies; 7+ messages in thread
From: Simon Wright @ 2014-10-08 19:48 UTC (permalink / raw)
Ludovic Brenta <ludovic@ludovic-brenta.org> writes:
>> Apparently one should use g++ rather than gcc, because it makes a better
>> job of it.
>>
>> GNAT GPL 2014 does translate (some) macros; it doesn't always get it
>> right, eg
>>
>> #define M_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */
>> #define M_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */
>> #define MAXFLOAT 0x1.fffffep+127f
>>
>> // have to have _something_ besides the constants or no .ads gets
>> // generated.
>> extern float sinf(float);
>>
>> turns into
>>
>> pragma Ada_2005;
>> pragma Style_Checks (Off);
>>
>> with Interfaces.C; use Interfaces.C;
>>
>> package math_h is
>>
>>
>> M_SQRT2 : constant := 1.41421356237309504880168872420969808; -- ./math.h:1
>> M_SQRT1_2 : constant := 8#.707106781186547524400844362104849039#; -- ./math.h:2
> ^^ ^
>
> Isn't that a blatant bug? Either in the Ada or in the C source?
Yes; like I said, it doesn't always get it right.
And it doesn't understand hex floats either: 16#1.fffffep+127f# is *not*
a good translation of 0x1.fffffep+127f !
I have reported these problems to AdaCore, but as they have always said
the translation isn't expected to be perfect, so it'll be very low on
their priority list.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-10-10 10:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-06 17:45 -fdump-ada-spec Simon Wright
2014-10-07 14:08 ` -fdump-ada-spec Stephen Leake
2014-10-07 16:05 ` -fdump-ada-spec Simon Wright
2014-10-07 15:12 ` -fdump-ada-spec Markus Schöpflin
2014-10-07 16:05 ` -fdump-ada-spec Simon Wright
2014-10-10 10:06 ` -fdump-ada-spec Simon Wright
-- strict thread matches above, loose matches on Subject: below --
2014-10-06 22:42 Newcomers to comp.lang.ada: welcome and how did you end up here ? Simon Clubley
2014-10-07 8:10 ` Gour
2014-10-07 10:49 ` Luke A. Guest
2014-10-08 7:23 ` Gour
2014-10-08 8:35 ` Brian Drummond
2014-10-08 9:15 ` Simon Wright
2014-10-08 19:14 ` -fdump-ada-spec (was: Newcomers to comp.lang.ada: welcome and how did you end up here ?) Ludovic Brenta
2014-10-08 19:48 ` -fdump-ada-spec Simon Wright
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox