Using a DLL function that returns a float 
Author Message
 Using a DLL function that returns a float

I have written a DLL in MS fortran that includes several functions which
return floating point values (REAL*4).  When calling these routines from
Visual Basic they work fine.  However, when calling them from a 'C' program
(or C++) I get an 'Processor Exception' error.  Functions that return
Integer values (INTEGER*2 or INTEGER*4) work fine.  Also, subroutines work
fine.  Only the functions returning floats give me the error.

Any thoughts on what is going on here?

Thanks for you help!

- Andrew



Wed, 18 Jun 1902 08:00:00 GMT  
 Using a DLL function that returns a float

Quote:

> I have written a DLL in MS Fortran that includes several functions which
> return floating point values (REAL*4).  When calling these routines from
> Visual Basic they work fine.  However, when calling them from a 'C' program
> (or C++) I get an 'Processor Exception' error.  Functions that return
> Integer values (INTEGER*2 or INTEGER*4) work fine.  Also, subroutines work
> fine.  Only the functions returning floats give me the error.

> Any thoughts on what is going on here?

> Thanks for you help!

> - Andrew

Are you storing the returned value into a "double or a "float" variable
in your program?

I know that MS C/C++ performs all operations in double arithmetic and
float is really only used for storage. A float variable gets converted
to double before it is used in an expression.

Regards,
--
Carlos Portela, Simple Software Solutions, Inc.
e_Db 2.1 - Fast, reliable database engine
e_Fs 2.0 - Portable structured storage
e_Comm 2.0 - Client-server communications
http://www.simple-sw.com



Wed, 18 Jun 1902 08:00:00 GMT  
 Using a DLL function that returns a float
See if http://home.sol.no/~arnholm/cppf77.htm is of any help (see for
example section 3.4 Prototyping a FUNCTION in C++).

There should be no problems in returning a REAL

--
Carsten Arnholm

http://home.sol.no/~arnholm/



Quote:
> I have written a DLL in MS Fortran that includes several functions which
> return floating point values (REAL*4).  When calling these routines from
> Visual Basic they work fine.  However, when calling them from a 'C'
program
> (or C++) I get an 'Processor Exception' error.  Functions that return
> Integer values (INTEGER*2 or INTEGER*4) work fine.  Also, subroutines
work
> fine.  Only the functions returning floats give me the error.

> Any thoughts on what is going on here?

> Thanks for you help!

> - Andrew



Wed, 18 Jun 1902 08:00:00 GMT  
 Using a DLL function that returns a float

Quote:

>I have written a DLL in MS Fortran that includes several functions which
>return floating point values (REAL*4).  When calling these routines from
>Visual Basic they work fine.  However, when calling them from a 'C' program
>(or C++) I get an 'Processor Exception' error.  Functions that return
>Integer values (INTEGER*2 or INTEGER*4) work fine.  Also, subroutines work
>fine.  Only the functions returning floats give me the error.

>Any thoughts on what is going on here?

    I seem to recall that there is an incompatibility between
    Microsoft C & Borland C compilers in the way a function
    value is returned. One returns it in the register and the other
    returns it in a variable on the stack (not sure about this).
    You're ok for function arguments, but the return value
    is a problem.

    Perhaps the MS FORTRAN return method is similarly
    mismatched with the C compiler?

--
John A. Grant  * I speak only for myself *  (remove 'z' to reply)
Airborne Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. DLL's returning an array of floats

2. Getting a float return value from a c function

3. IVF odd behaviour: subroutine vs function returning floating point number

4. returning ARRAY structures from DLL-functions in Dyalog

5. returning multiple data from c function dll

6. call function from dll with return void*

7. Call function from DLL with return type void*

8. DLL functions that return char *

9. Calling a dll c function returning a pointer

10. How to return [any] DLL version info using TCL

11. question about writing to the return value of a system function using vpi_put_value()

12. Using external DLL functions in a method

 

 
Powered by phpBB® Forum Software