www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/06/21:08:03

Message-ID: <34B2E2D2.81F632BF@ix.netcom.com>
Date: Tue, 06 Jan 1998 20:05:06 -0600
From: Kurt Wall <kwall AT ix DOT netcom DOT com>
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: 'Register' in C
References: <01bd1ae1$2f536440$d83d63c3 AT default> <34B29809 DOT 8841108D AT pentek DOT com>

Yup! "register" is just a suggestion to the compiler.  Most optimizers
do a better job anyway.

Kurt

Charles Krug wrote:
> 
> Ross Boast wrote:
> 
> > Hi Guys,
> >              This is driving me mad I can't find any information on the web
> > regarding the syntax of 'register' this doesn't work:
> >
> > register char buf[100];
> 
> Think about that--you're asking to assign a non-pointer variable named buf,
> which is a 100 element array, to a register.  Would you do that?
> Despite frequent similarities, an array is not a pointer--just try the
> expression "buf = &fred" and see where that gets you.
> 
> If you want to create a register variable which points to the base of the char
> array buf[], you need this:
> 
> char buf[100];
> register *char bufptr = buf;
> 
> Now bufptr is a register variable of type "pointer to char", which is probably
> what you're after.  ALSO--remember that "register" is a suggestion, not a
> requirement.  SOME compilers will ignore your suggestion, and giving the
> compiler impossible combinations of register variables will give "unpredictable
> results."  Also, be aware that declaring variables "register" does not always
> boost performance.
> 
> Have you tried compileing w/ full optimizations yet?  Its likely to give better
> results than you or I could come up with.
> 
> --
> Charles Krug, Jr.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019