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 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On Mon, 14 Sep 1998 16:33:45 -0700, "jud" wrote: > ------=_NextPart_000_0008_01BDDFFD.715D45E0 > Content-Type: text/html; > charset="iso-8859-1" > Content-Transfer-Encoding: quoted-printable > > > > > > http-equiv=3DContent-Type> > > > >
>

what deos the keyword register do with variables > size=3D2>?

>

pleas send replis to href=3D"mailto:jud AT tminet DOT com">jud AT tminet DOT com

= > > > ------=_NextPart_000_0008_01BDDFFD.715D45E0-- 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.