www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/14/21:47:24

From: jackklein AT worldnet DOT att DOT net (Jack Klein)
Newsgroups: alt.comp.lang.learn.c-c++,comp.os.msdos.djgpp
Subject: Re: what deos the keyword register do with variables
Date: 15 Sep 1998 01:30:03 GMT
Organization: AT&T WorldNet Services
Lines: 59
Message-ID: <3601c18d.98650003@netnews.worldnet.att.net>
References: <6tk9u9$jom$1 AT supernews DOT com>
NNTP-Posting-Host: 12.66.226.175
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Mon, 14 Sep 1998 16:33:45 -0700, "jud" <jud AT tminet DOT com> wrote:

> ------=_NextPart_000_0008_01BDDFFD.715D45E0
> Content-Type: text/html;
> 	charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
> <HTML>
> <HEAD>
> 
> <META content=3Dtext/html;charset=3Diso-8859-1 =
> http-equiv=3DContent-Type>
> <META content=3D'"MSHTML 4.71.1712.3"' name=3DGENERATOR>
> </HEAD>
> <BODY bgColor=3D#ffffff>
> <DIV><FONT size=3D1>
> <P>what deos the keyword register do with variables<FONT color=3D#000000 =
> 
> size=3D2>?</FONT></P>
> <P><FONT color=3D#000000 size=3D2>pleas send replis to <A=20
> href=3D"mailto:jud AT tminet DOT com">jud AT tminet DOT com</A></FONT></P></FONT></DIV>=
> </BODY></HTML>
> 
> ------=_NextPart_000_0008_01BDDFFD.715D45E0--

<Jack>

It is considered very bad manners to post HTML to usenet discussion groups.
Turn that damn feature off.  It is considered very bad manners to ask for
email responses.  Usenet is not a write only medium, and if your question is
important enough for you to expect thousands of people to read it you better
be prepared to make the effort to read the newsgroup for the answers.

Now as to your question.

The register keyword is a hint to the compiler that a particular variable will
be used heavily and should be allocated somewhere where it can be accessed as
quickly as possible.  This could mean in a processor register, if the
processor has registers.

Depending on the processor and compiler, there may be registers or fast access
memory areas available for a certain number of certain types of variables, or
there may not.  The compiler is perfectly free to ignore the register keyword
if it decides to do so.  If it does honor the keyword it may actually result
in poorer code because it might prevent the compiler from doing the best job
of optimizing the code on its own.

If a variable defined with the register keyword is not actually placed in a
register by the compiler it is treated like an ordinary auto variable (a local
variable defined inside a function without the static keyword).

Regardless of whether or not the compiler honors the register request, you
cannot take the address of a register variable with the & operator.  Otherwise
you can perform any operations on a register variable that you can on any
other variable of the same type.

</Jack>

- Raw text -


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