From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: Register Variable Question? Date: Mon, 16 Dec 1996 21:06:30 +0000 Organization: None Lines: 43 Distribution: world Message-ID: <7lld+CAWnbtyEwMN@talula.demon.co.uk> References: <19961215 DOT 150724 DOT 3694 DOT 0 DOT MSnakes AT juno DOT com> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Matt J Reiferson writes: >I want to have a couple of global register int variables in my program to >get the most speed out of a couple of functions, when I compile I get an >error message saying: > register name not specified for 'int sliver_column' > >The line it refers to is: > register int sliver_column I very much doubt that global variables can be allocated to registers. Think what this would mean: no code, anywhere in your program, could use these registers! Because of the way C compiles each source files as an individual unit, there is no way that this could be enforced. You shouldn't need to explicitly declare them as register variables, though. The gnu optimiser is quite smart enough to temporarily move variables into registers as required (eg. when they are being used inside a tight loop), and then to later swap them out in favour of something else. It is far better to leave this sort of decision to the compiler: it's more portable, and the compiler has a lot more control over exactly where things go that you would with a simple 'register' definition. If you are really concerned about efficiency, though, you shouldn't make the variables global. Think about it: every time you call an external function, the compiler has no way of knowing if the variable has been changed. For example, if foo is a global int, the code: for (i=0; i