From: Albert G. <Dr....@t-...> - 2008-08-30 21:35:41
|
Eddie Rucker wrote: > Um... Is there some way from Pure to find out the byte sizeof ints, > doubles, complex, etc? When the sizes change on different machines > and/or compilers I'd like the library to automatically handle this. FWIW, system.pure now provides the following constants. These probably aren't of much use for figuring out struct alignment, but at least they provide the necessary information to malloc pointers to these types in a portable manner. Also, you can test whether you're on a 64 bit system by inspecting SIZEOF_POINTER. (BTW, I see no point in adding the long double types right now, since these aren't supported by Pure in any way.) > using system; > list -g SIZEOF* const SIZEOF_BYTE = 1; const SIZEOF_COMPLEX_DOUBLE = 16; const SIZEOF_COMPLEX_FLOAT = 8; const SIZEOF_DOUBLE = 8; const SIZEOF_FLOAT = 4; const SIZEOF_INT = 4; const SIZEOF_LONG = 4; const SIZEOF_LONG_LONG = 8; const SIZEOF_POINTER = 4; const SIZEOF_SHORT = 2; The complex sizes are for the ISO C99 complex float and double types. I don't know how portable that is, but gcc surely has them and they're also in POSIX. Is it true that complex double is just two doubles, similar for complex float? That would make things much easier, because a complex matrix could be represented internally as a double matrix with twice the number of columns. I guess that ISO C99 implementations are free to choose the internal representation, though. Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |