[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: data types
- Subject: Re: data types
- From: Nigel Wade <nmw(at)ion.le.ac.uk>
- Date: Thu, 01 Feb 2001 14:01:20 +0000
- Newsgroups: comp.lang.idl-pvwave
- Organization: University of Leicester, UK
- References: <95b8qc$5un$1@nnrp1.deja.com>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:23345
graham_wilson@my-deja.com wrote:
>
> I'm trying to compile a short listing of data types for converting
> between F77, C, and IDL.
>
> Below is a listing of what I have but note that I have not filled in all
> of the IDL column. Any and all comments/help is appreciated and my
> appologies to those of you who don't use fixed fonts for reading mail.
>
> F77 type C type IDL type Size
> (bytes)
> -----------------------------------------------------------------------
> byte x char x byte 1
> character x char x byte 1
> character*n x char x[n] bytearr(n) n
>
> complex x struct {float r, i;} x ? 8
> complex*8 x struct {float r, i;} x ? 8
> double complex x struct {float dr, di;} x ? 16
> complex*16 x struct {float dr, di;} x ? 16
> complex*32 x struct {float dr, di;} x ? 32
>
> double precision x double double 8
> real x float x float 4
> real*4 x float x float 4
> real*8 x double x double 8
> real*16 x long double x ? 16
>
> integer x int x long 4
> integer*2 x short x fix 2
> integer*4 x int x long 4
> integer*8 x long long int x ? 8
>
> logical x int x long 4
> logical*1 char x byte 1
> logical*2 short x fix 2
> logical*4 int x long 4
> logical*8 long long int x ? 8
>
> NB: I'm assuming that there are no fancy compiling options given to
> change the alignment or the default sizes.
>
> Such a list would be useful as an appendix in one of those IDL books we
> keep hearing about (better still if it had the byte alignment for
> sparc/intel/powerpc/dec/mips...) :p
>
> Sent via Deja.com
> http://www.deja.com/
IDL's COMPLEX type will match a C struct {float r; float i; } provided
a C float is the same as a float in IDL and there is no padding inserted
by the C compiler. DCOMPLEX should match struct { double r; double i}.
AFAIK IDL does not have a 64 bit float. It does now have LONG64 which
should match your integer*8 and long long int.
Your double complex, complex*16 and complex*32 would appear to be
inconsistent with your normal complex. Two floats cannot be 8, 16 and 32
bytes!
You don't say which platform your table is for. As I am sure you are
aware
ANSI C places very few restrictions on the sizes of the basic types, and
no restriction on padding within structures. So you need to be very
specific in saying for what platform/compiler/compiler-defaults the
values are valid.
--
-----------------------------------------------------------
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523568, Fax : +44 (0)116 2523555