comp.lang.ada
 help / color / mirror / Atom feed
* Passing Floats Ada->C
@ 1998-07-27  0:00 Dennis Miller
  1998-07-27  0:00 ` Rick Stikkers
  1998-07-28  0:00 ` Matthew Heaney
  0 siblings, 2 replies; 4+ messages in thread
From: Dennis Miller @ 1998-07-27  0:00 UTC (permalink / raw)


Has anyone encountered any difficulties in sending float values from Ada
to C?

--
Dennis Miller, Software Engineer
C4I Applications Section
Market Solutions Division
Motorola SSG

"If a man says something and a woman
 isn't around, is he still wrong?"

---Remove xxx from e-mail address to reply---






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Passing Floats Ada->C
  1998-07-27  0:00 Passing Floats Ada->C Dennis Miller
@ 1998-07-27  0:00 ` Rick Stikkers
  1998-07-28  0:00 ` Matthew Heaney
  1 sibling, 0 replies; 4+ messages in thread
From: Rick Stikkers @ 1998-07-27  0:00 UTC (permalink / raw)


I had that problem one time with integers.  The problem I had there was that
I was trying to pass a variable that was inside a structure that I had used
the for ... use at ... clause on (a favorite among you boys at Motorola).
The problem was that the variable I was trying to pass was not on an even
word boundary, so it did not like it.  I don't remember if it gave me a
runtime error or just blew up.  I know it compiled fine, though.  The
workaround I ended up with was I declared another integer (temp) inside the
procedure I was working in, set temp equal to the variable I was trying to
pass, then passed the temp variable to the C procedure.  It seems to work
fine that way.


                                            Rick Stikkers

Dennis Miller wrote in message <35BCA22D.DB070D0F@email.mot.com>...
>Has anyone encountered any difficulties in sending float values from Ada
>to C?
>
>--
>Dennis Miller, Software Engineer
>C4I Applications Section
>Market Solutions Division
>Motorola SSG
>
>"If a man says something and a woman
> isn't around, is he still wrong?"
>
>---Remove xxx from e-mail address to reply---
>
>






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Passing Floats Ada->C
  1998-07-27  0:00 Passing Floats Ada->C Dennis Miller
  1998-07-27  0:00 ` Rick Stikkers
@ 1998-07-28  0:00 ` Matthew Heaney
  1998-07-28  0:00   ` Keith Thompson
  1 sibling, 1 reply; 4+ messages in thread
From: Matthew Heaney @ 1998-07-28  0:00 UTC (permalink / raw)


Dennis Miller <Dennis_Miller-P28917xxx@email.mot.com> writes:

> Has anyone encountered any difficulties in sending float values from Ada
> to C?

The problem I've had in the past is that Float in Ada sometimes means
something else in C, say long float.  Make sure the underlying
representations are the same.

If you're using Ada 95, you shouldn't have a problem if you stick to the
types in package Interfaces.C, and remember to use pragma Convention (C)
on your subprograms.










^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Passing Floats Ada->C
  1998-07-28  0:00 ` Matthew Heaney
@ 1998-07-28  0:00   ` Keith Thompson
  0 siblings, 0 replies; 4+ messages in thread
From: Keith Thompson @ 1998-07-28  0:00 UTC (permalink / raw)


I've deleted comp.lang.c++ from the Newsgroups: header, since this isn't
a C++ question.

Matthew Heaney (matthew_heaney@acm.org) wrote:
[...]
> The problem I've had in the past is that Float in Ada sometimes means
> something else in C, say long float.  Make sure the underlying
> representations are the same.
> 
> If you're using Ada 95, you shouldn't have a problem if you stick to the
> types in package Interfaces.C, and remember to use pragma Convention (C)
> on your subprograms.

Note that in C, if there's no prototype (or a ", ..." prototype) in scope,
arguments of type float are promoted to type double.

This is more likely to be a problem passing floats from C to Ada, but
it's something to watch out for.  As long as you properly prototype
everything, it should seldom be an issue.

-- 
Keith Thompson (The_Other_Keith) kst@cts.com <http://www.ghoti.net/~kst> <*>
Qualcomm, San Diego, California, USA  <http://www.qualcomm.com>
It takes a Viking to raze a village.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1998-07-28  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-07-27  0:00 Passing Floats Ada->C Dennis Miller
1998-07-27  0:00 ` Rick Stikkers
1998-07-28  0:00 ` Matthew Heaney
1998-07-28  0:00   ` Keith Thompson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox