Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!ncc!adec23!mark From: mark@adec23.UUCP (Mark Salyzyn) Newsgroups: comp.lang.c Subject: Re: Short code to determine compiler's Summary: Nope, asking the compiler is not the answer Message-ID: <1706@adec23.UUCP> Date: 24 Jul 89 20:26:44 GMT References: <396@uop.uop.EDU> <225800197@uxe.cso.uiuc.edu> <579@targon.UUCP> Followup-To: comp.lang.c Organization: ADEC Systems Inc., Edmonton, Alberta Lines: 25 In article <579@targon.UUCP>, andre@targon.UUCP (andre) writes: >Yes, I think you can write a program that checks the nr of registers, > ... >main() >{ > register n1, n2, n3, n4, n5, n6, n7, n8; /* etc. */ > int *a; > a = &n8; > /* repeat n6 - n2 */ > a = &n1; >} >You can take the address of a variable but not of a register. I have several compilers (Aztec C-80, MSC3.0, SYSV cc) that will complain with ALL of the address taking and only assign a pair of them to registers. I'm sorry but this is not the answer. I can't even find in the source code of the C compiler how many registers are used :-). As far as runtime is concerned, just do a decrement loop on each of the register variables and check the time. The non-register variables will take longer to do the loop (probably???). In my next posting I will divulge the secrets of the Universe :-) :-). Ciao, -- Mark Salyzyn