From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: *** X-Spam-Status: No, score=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6c7be346cfa17c37 X-Google-Attributes: gid103376,public From: "David C. Hoos, Sr." Subject: Re: Ada/Motif problem... Date: 1996/08/28 Message-ID: <01bb94d3$613fc4c0$328371a5@dhoossr.iquest.com>#1/1 X-Deja-AN: 176926434 distribution: world references: <4vupg6$ljf@goanna.cs.rmit.edu.au> content-type: text/plain; charset=ISO-8859-1 organization: DBH Enterprises, Inc. mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-08-28T00:00:00+00:00 List-Id: 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 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 >