www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/26/22:20:52

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: register int variable Errors
Date: Wed, 26 Feb 1997 21:28:49 -0800
Organization: Two pounds of chaos and a pinch of salt
Lines: 33
Message-ID: <33151B91.D39@cs.com>
References: <ws6jCCAYMEFzEwZ0 AT jenkinsdavid DOT demon DOT co DOT uk>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp202.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

David Jenkins wrote:
> 
> register int d;
> 
> DJGPP gives the error "register name not specified for 'd'

Is 'd' a global variable?  If so, you must explicitly specify what
register to place it in (I don't know how - see the GCC extensions in
the docs) or the compiler won't know how to handle it.  Every guide I
have seen recommends against storing global variables in registers,
because they reduce the registers available to EVERY OTHER function in
your program!  This can have serious side-effects, particularly on
library code.  (Actually, I don't see how library code can work at all -
anybody else have any knowledge on this subject?)

If this isn't what you are doing, then _please_ post the complete code
that generates the error, or at least enough code for one of us to
reproduce the error on our own.  However, the obvious solution that I
can see would be to make 'd' a local variable.  Then you can store it in
a register without any further fuss.

One final note:  you should compile your programs with optimizations
('-O' switch) to get full use of registers for variables.  In fact,
doing this may make gcc produce faster code than you could have done
yourself!  You should try it and see what it does for you.

-- 
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I  |        fighteer AT cs DOT com         |
| "Starting flamewars since 1993"  |   http://www.cs.com/fighteer   |
|  *** NOTICE ***  This .signature is generated randomly.           |
|                  If you don't like it, sue my computer.           |
---------------------------------------------------------------------

- Raw text -


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