From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: Ada/Motif problem...
Date: 1996/08/28
Date: 1996-08-28T00:00:00+00:00 [thread overview]
Message-ID: <01bb94d3$613fc4c0$328371a5@dhoossr.iquest.com> (raw)
In-Reply-To: 4vupg6$ljf@goanna.cs.rmit.edu.au
Hi Dale,
It appears that your problem is passing an Ada string where an XtPointer is
required. This confusion may result from the fact that in C a literal
string is stored as a null-terminated static string in a memory location
determined by the compiler/linker, and that the value of that literal
string expression is its address. Further, if you are compiling the C
without strict ANSI constraints, that pointer to char will be accepted as a
valid XtPointer!
I haven't worked with these X11Ada bindings yet, but I would suggest the
string "Hello World" & Ascii.NUL be assigned to an object declared as
aliased -- e.g.,
Hello_World : aliased constant STRING := "Hello World" & Ascii.NUL;
Then I would pass the value Hello_World'ACCESS as the parameter.
The reason I am suggesting the explicit NUL termination for the string, is
that that's what the X11 library, written in C expects. There may be some
fancier way with some of the packages in the Ada95 annexes, but I haven't
learned enough about them yet.
Hope this helps
--
David C. Hoos, Sr.,
http://www.dbhwww.com
http://www.ada95.com
Dale Stanbrough <dale@goanna.cs.rmit.EDU.AU> wrote in article
<4vupg6$ljf@goanna.cs.rmit.edu.au>...
> Hi,
>
> One of our students has run into problems writing a Motif routine.
> The callback data is to be a string as follows..
>
>
> Xt.Intrinsic.XtAddCallback(
> pb,
> Motif.xmstrdefs.XmNactivateCallback,
> hello_dialog_pkg.popup'access,
> "Hello World");
>
>
> I've tried using unchecked_conversion from an access to all string
> to XtPointer, but Gnat complains (quite rightly) about these pointer
> types being of different sizes.
>
> Any inspiration on how to pass Ada strings as callback data in Motif?
>
> Here's the subprogram declaration...
>
> procedure XtAddCallback(
> widget : Xt.Intrinsic.Widget;
> callback_name: X.Strings.const_charp;
> callback : XtCallbackProc;
> closure : XtPointer);
>
> Dale
>
next prev parent reply other threads:[~1996-08-28 0:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-08-27 0:00 Ada/Motif problem Dale Stanbrough
1996-08-27 0:00 ` Larry Kilgallen
1996-08-27 0:00 ` Dale Stanbrough
1996-08-27 0:00 ` Michael K Rohan
1996-08-28 0:00 ` Larry Kilgallen
1996-08-29 0:00 ` Paul Hussein
1996-08-28 0:00 ` Jon S Anthony
1996-08-28 0:00 ` David C. Hoos, Sr. [this message]
1996-08-29 0:00 ` Jon S Anthony
1996-08-29 0:00 ` Dale Stanbrough
1996-09-02 0:00 ` Sandy McPherson
-- strict thread matches above, loose matches on Subject: below --
1996-08-28 0:00 G. Vincent Castellano
1996-08-28 0:00 W. Wesley Groleau (Wes)
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox