From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,76b62d6ecdceb3c4,start X-Google-Attributes: gid1164f8,public From: Larry W Loen Subject: 32 and 64 bit questions Date: 1999/11/04 Message-ID: <38220B81.B04EC3EE@rchland.vnet.ibm.com>#1/1 X-Deja-AN: 544580128 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.rchland.ibm.com X-Trace: news.rchland.ibm.com 941755273 25276 9.5.66.93 (4 Nov 1999 22:41:13 GMT) Organization: IBM Rochester MN Mime-Version: 1.0 NNTP-Posting-Date: 4 Nov 1999 22:41:13 GMT Newsgroups: comp.sys.dec As you can tell by the company I work for, I don't have much to do professionally with DEC systems. But, I am a bit puzzled at some things I read and have been told over the years about Alpha and C/C++. Particularly, exactly how elementary C scalars are "sizeof-ed" on DEC C/C++ compilers. I was once told that the C construct "long" was supposed to be 64 bits for Alpha, but reading about the DEC C and DEC C++ compiler manuals on-line more or less contradicts it. For instance, the max and min for long are 32 bits in limits.h for both C and C++ books. That says long is "always" 32 bits. There's lots of talk in the C manual about __intial_pointer_size and nothing about long as other than 32 bits. Yet, the __32BIT macro variable in the C++ manual selects a mode where "long and pointer are both 32 bits" (implying, perhaps, that long is 64 bits on Alpha). There is a section about getting your data types right which states pretty openly that long can be 64 bits at least some of the time. Yet, it also states min and max consistent with 32 bits near as I can tell. I know things like int64 and int32 are available via includes and so on, but what I want to know is if something like this is accurate: sizeof Compiler int long void* Notes DEC C 4 4 4 or 8 4 when __32BIT DEC C++ VMS 4 4 or 8 4 or 8 4 and 4 when __32BIT 8 and 8 otherwise DEC C++ Unix 4 4 4 __32BIT is defined?? (where DEC C++ Unix means "the target is Unix"). Will a compile targeting Unix always define __32BIT? BTW, do VAX compiles always set __32BIT now for C/C++? Are the long LONGMIN and LONGMAX set right if long is allowed to be 64 bits? I am guestimating that predefined macro variables are: DEC C __intitial_pointer_size defined when 64 bit pointers possible undefined when __32BITS is defined DEC C++ __32BITS when long and void* always 64 bits. C++ does not seem to allow any 32 and 64 mixed mode where pointers can be sometimes 32 and other times 64. and that I would do something like: #ifdef __DECCXX_VER #ifdef __ALPHA /* meaning VMS and not Unix */ #ifdef __32BITS #define SIZEOFLONG 4 #define SIZEOFVOIDSTAR 4 #else #define SIZEOFLONG 8 #define SIZEOFVOIDSTAR 8 #endif /* __32BITS */ #else #define SIZEOFLONG 4 #define SIZEOFVOIDSTAR 4 #endif /* __ALPHA */ #endif /* DEC C */ #ifdef __DECC_VER #define SIZEOFLONG 4 #ifdef __initial_pointer_size #define SIZEOFVOIDSTAR __initial_pointer_size #else #define SIZEOFVOIDSTAR 4 #endif /* __initial_pointer_size */ #endif /* DEC C++ */ to find out about the sizes of any particular environment my code found itself in. BTW, what rules does GNU for Alpha follow? Disclaimer: I certainly don't want any proprietary stories on this, just a simple explanation of how things are.