Mail Archives: djgpp/1998/01/06/21:08:03
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 -