[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fwd: ncdigest V1 #574]
- Subject: [Fwd: ncdigest V1 #574]
- Date: Fri, 09 Feb 2001 13:00:09 -0700
Date: Thu, 8 Feb 2001 10:19:58 +0100
From: =?iso-8859-1?Q?Jos=E9_Mar=EDa_Gonz=E1lez_Ondina?=
<address@hidden>
Subject: Re: problem using netcdf and Borland Delphi
> I am trying to read some cdf data files using Borland Delphi v 5.0 on a
> Windows NT machine. I downloaded netcdf.dll from the unidata ftp site
>
(ftp://ftp.unidata.ucar.edu/pub/netcdf/contrib/win32/netcdf-3.5-beta5.win32b
> in.ZIP) and put the following definitions in my Delphi code:
>
> function nc_inq_libvers : pchar; external 'netcdf.DLL';
> function nc_strerror (ncerr : integer) : pchar; external 'netcdf.DLL';
> function nc_open (path : pchar; omode : integer; var ncidp : integer) :
> integer; external 'netcdf.DLL';
> function nc_close (ncidp : integer) : integer; external 'netcdf.DLL';
>
> When I call nc_inq_libvers I get what appears (?) to be a reasonable
answer:
>
> 3.5-beta5 of Oct 17 2000 10:28:35 $
>
> but when I call nc_strerror with any integer (I tried a lot of them), I
> always get back
I think the problem can be in the calling convention and perhaps with
the
type of the parameter.
I have been mixing Delphi with DLLs made in Visual C++, and here is an
examples of external function declaration, perhaps it may help you.
Delphi Declaration:
function SetValue(Variable: PChar; VariableLength: Cardinal;
Value: PChar; ValueLength: Cardinal;
var Index, ValueType: Cardinal): Integer; cdecl;
external 'Intermed.dll';
DLL C++ declaration:
#define DllExport extern "C" __declspec( dllexport )
enum TValueType {vtNone=0, vtReal, vtInteger, vtString, vtRealVector};
DllExport int SetValue(char *Variable, unsigned int VariableLength,
char *Value, unsigned int ValueLength, int
*Index,
TValueType *ValueType);
As you can see, C++'s ints have been replaced by Delphi's Cardinal,
and
the calling convention have been set to "cdecl".
The only way I know to determine which calling convention you have to
use
and which are the types that match C++ (or other languages) types is
test
and error (and sometimes a little of inspection of the CPU window).
By the way, I am very interested in use NetCDF from Delphi in the
future,
but now I don´t have the time to do the porting. I'll like very much if
you
keep me informed of your progress.
Of course, if I can help you just write me.
José María González Ondina.
address@hidden
------------------------------
Date: Thu, 08 Feb 2001 14:06:17 +0100
From: Catrin Pieri <address@hidden>
Subject: Delphi and NetCDF
Dear Sandy,
You should use cdecl; as calling convention. See Delphi help for
details.
e.g. i use :
function nc_open(const path : Pchar; mode : integer; var ncidp :
integer):integer; cdecl; external 'netcdf.dll';
which works fine with Version 3.4 of NetCDF but the version should not
be
relevant.
Best regards Catrin
- --
____________________________________________________________________________
Catrin Pieri
HYDROMOD Wissenschaftliche Beratung GbR -- HYDROMOD Scientific
Consulting
Büroadresse / Office address: Bahnhofstr. 52, D-22880 Wedel
Postanschrift / Postal Address: Postfach 1229, D-22871 Wedel
Tel.: 04103 / 9 12 23-0 Fax: 04103 / 9 12 23-23
mailto:address@hidden http://www.hydromod.de
____________________________________________________________________________
------------------------------
End of ncdigest V1 #574
***********************