473,626 Members | 3,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Limit on maximum number of register variable in C program

Hi All
Is there a limit on the number of register variables that can be
declared and initialized in a C program on a particular hardware
platform? If you define more number of register variables than the
processor has, how is it handled by the C compiler?

regards

Nov 14 '05 #1
16 3740

<al***********@ gmail.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...
Hi All
Is there a limit on the number of register variables that can be
declared and initialized in a C program on a particular hardware
platform?
No. However, the compiler is not obliged to honour any of them.
If you define more number of register variables than the
processor has, how is it handled by the C compiler?


By ignoring the "register" keyword for most/all of the variables you
declared that way.

Using the "register" keyword is seldomly very desirable. In most cases, an
optimizing compiler
will put variables in a register anyway (if it can, that is). Hence the
keyword 'volatile" which explicitly prevents this.

The only case where "register" is handly, is when you want to pass a hint to
the compiler about what to optimize.
Nov 14 '05 #2
<posted & mailed>

The register keyword is merely a hint to the compiler. it doesn't force a
variable into a register. So, there's no limit to what can be declared
register, or how many variables. The compiler will simply choose some and
ignore the rest.

al***********@g mail.com wrote:
Hi All
Is there a limit on the number of register variables that can be
declared and initialized in a C program on a particular hardware
platform? If you define more number of register variables than the
processor has, how is it handled by the C compiler?

regards


--
Remove '.nospam' from e-mail address to reply by e-mail
Nov 14 '05 #3
"dandelion" <da*******@mead ow.net> writes:
<al***********@ gmail.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...
Hi All
Is there a limit on the number of register variables that can be
declared and initialized in a C program on a particular hardware
platform?


No. However, the compiler is not obliged to honour any of them.
If you define more number of register variables than the
processor has, how is it handled by the C compiler?


By ignoring the "register" keyword for most/all of the variables you
declared that way.


It can't completely ignore it; it still has to forbid (or at least
issue a diagnostic for) any attempt to take the address of a
register-qualified variable.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #4
Keith Thompson <ks***@mib.or g> writes:
"dandelion" <da*******@mead ow.net> writes:
By ignoring the "register" keyword for most/all of the variables you
declared that way.


It can't completely ignore it; it still has to forbid (or at least
issue a diagnostic for) any attempt to take the address of a
register-qualified variable.


A lousy implementation might issue a warning for taking the
address of *any* variable, I suppose.
--
"To get the best out of this book, I strongly recommend that you read it."
--Richard Heathfield
Nov 14 '05 #5
In article <87************ @benpfaff.org>,
Ben Pfaff <bl*@cs.stanfor d.edu> wrote:
Keith Thompson <ks***@mib.or g> writes:
"dandelion" <da*******@mead ow.net> writes:
By ignoring the "register" keyword for most/all of the variables you
declared that way.


It can't completely ignore it; it still has to forbid (or at least
issue a diagnostic for) any attempt to take the address of a
register-qualified variable.


A lousy implementation might issue a warning for taking the
address of *any* variable, I suppose.


A rather more reasonable way to avoid doing the work of recognizing this
case is to issue a warning any time it sees the register keyword.
dave

--
Dave Vandervies dj******@csclub .uwaterloo.ca
I will really not become the pilot, policeman or professional soccer player of
my childhood dreams, for I had none. I always envisioned myself still playing
with lego all those eons later. --Pim van Riezen in the scary devil monastery
Nov 14 '05 #6
On Wed, 23 Feb 2005 22:45:52 +0000 (UTC), dj******@csclub .uwaterloo.ca
(Dave Vandervies) wrote:
In article <87************ @benpfaff.org>,
Ben Pfaff <bl*@cs.stanfor d.edu> wrote:
Keith Thompson <ks***@mib.or g> writes:
"dandelion" <da*******@mead ow.net> writes:
By ignoring the "register" keyword for most/all of the variables you
declared that way.

It can't completely ignore it; it still has to forbid (or at least
issue a diagnostic for) any attempt to take the address of a
register-qualified variable.


A lousy implementation might issue a warning for taking the
address of *any* variable, I suppose.


A rather more reasonable way to avoid doing the work of recognizing this
case is to issue a warning any time it sees the register keyword.

Yechh. I have to work with a (HP-UX) compiler which issues a warning
every time it sees "const", whether or not it's used properly.

--
Al Balmer
Balmer Consulting
re************* ***********@att .net
Nov 14 '05 #7
> <al***********@ gmail.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...
Hi All
Is there a limit on the number of register variables that can be
declared and initialized in a C program on a particular hardware
platform?

The standard puts it best: "A declaration of an identifier for an
object with storage-class specifier register suggests that access
to the object be as fast as possible. The extent to which such
suggestions are effective is implementation-defined."

So, register is simply a hint to the compiler, although the compiler
is free to ignore the hind.

dandelion wrote: No. However, the compiler is not obliged to honour any of them.
If you define more number of register variables than the
processor has, how is it handled by the C compiler?
By ignoring the "register" keyword for most/all of the variables you
declared that way.

Using the "register" keyword is seldomly very desirable.


That's overstating it.
In most cases, an optimizing compiler will put variables in a register anyway (if it can, that is).
True.
Hence the keyword 'volatile" which
explicitly prevents this.


No. The volatile keyword is a type qualifier, not a storage specifier.
It serves a different purpose. They are not mutually exclusive.

#include <stdio.h>

int main()
{
register volatile int x = 42;
printf("%d\n", x);
return 0;
}
--
Peter

Nov 14 '05 #8
In article <s8************ *************** *****@4ax.com>,
Alan Balmer <al******@spamc op.net> wrote:
On Wed, 23 Feb 2005 22:45:52 +0000 (UTC), dj******@csclub .uwaterloo.ca
(Dave Vandervies) wrote:
In article <87************ @benpfaff.org>,
Ben Pfaff <bl*@cs.stanfor d.edu> wrote:
[discussing appropriate diagnostics for an implementation that ignores
`register']
A lousy implementation might issue a warning for taking the
address of *any* variable, I suppose.
A rather more reasonable way to avoid doing the work of recognizing this
case is to issue a warning any time it sees the register keyword.

Yechh. I have to work with a (HP-UX) compiler which issues a warning
every time it sees "const", whether or not it's used properly.


This is much less unreasonable for register than it is for const, just
because of the way the two are used.

But even for const... would you prefer that the compiler warned every
time the code modified an object, because that object could have been
declared const and the compiler knew it ignored the const if there was
one and might therefore have missed a constraint violation?
dave

--
Dave Vandervies dj******@csclub .uwaterloo.ca Well, it's rather far from rocket science, mixing it up....

Actually, I hear it's a primary ingredient in the space shuttle's solid rocket
boosters. --Ingvar the Grey and Phillip Jones in the Scary Devil Monastery
Nov 14 '05 #9
dj******@csclub .uwaterloo.ca (Dave Vandervies) wrote:
Alan Balmer <al******@spamc op.net> wrote:
Yechh. I have to work with a (HP-UX) compiler which issues a warning
every time it sees "const", whether or not it's used properly.


This is much less unreasonable for register than it is for const, just
because of the way the two are used.

But even for const... would you prefer that the compiler warned every
time the code modified an object, because that object could have been
declared const and the compiler knew it ignored the const if there was
one and might therefore have missed a constraint violation?


I'd rather that it warn every time I assigned away the const, or assign
to a known-const object. The compiler _knows_ which objects are const;
it also knows when I do something unsafe with one of them.

Richard
Nov 14 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2002
by: Randell D. | last post by:
Folks, Sorry for the cross post into multiple newsgroups on this, but html forms processing is supported across all three groups so I was hoping someone might know. I did a check with Google and found dated 1996 and 1997... This is a bit too old for me to rely on... Thus... Does anyone know if there is a limit when POSTing? I think a
4
3495
by: karthik | last post by:
I have a partitioned view sitting over several tables and I'm slowly approaching the 256 number. Can anybody confirm if there is such a limit for the maximum number of tables that a partitioned view can hold? If this is true, does anybody have any suggestions or ideas to work around this max limit? TIA!
3
4438
by: mgPA | last post by:
Short: How can I limit the number of concurrent logins to Access (2000) DB? Long: I seem to be having the problem discussed in previous postings of having more than 9 or 10 concurrent logins. If I can limit the number of concurrent logins to 8 or 9, that would satisfy our needs. Thanks
9
10827
by: Terry E Dow | last post by:
Howdy, I am having trouble with the objectCategory=group member.Count attribute. I get one of three counts, a number between 1-999, no member (does not contain member property), or 0. Using LDIFDE as a comparison I get the same results. No members means just that, an empty group. Zero means that the DirectorySearcher.SizeLimit has been exceeded....
0
1860
by: Tomas | last post by:
I have two questions: (1) How (if possible) can you, with ASP.NET (and with the IIS 5 included with win2000) specify an maximum limit of the memory that a web application may consume, as an absolute number of megabytes ??? ( I am aware of the "memoryLimit" attribute in the "processModel" element in the Web.config but that only specifies the maximum allowed memory size, as a percentage of total system memory, and I don't want a...
4
10766
by: Bill | last post by:
Hi, I would be grateful if someone could clarify my rather confused ideas of the 10 connection limit on XP/2000 when its being used as a server. (I realise that XP is really a client op sys with limited server capability, I am also aware you can kludge the number to 40, but assume I do not want to do that). As I understand it XP Pro will support 10 simultaneous inbound (SYN) connections (5 for XP Home). My confusion arises as to what...
29
5086
by: garyusenet | last post by:
I'm trying to investigate the maximum size of different variable types. I'm using INT as my starting variable for exploration. I know that the maximum number that the int variable can take is: 65,535. But i'm trying to write a program to test this, assuming I didn't know this number in advance. I came up with the following but have two questions. Maybe someone can help? using System; using System.Collections.Generic; using System.Text;
1
3165
by: | last post by:
Hello everyone, I am using a textbox for dumping information generated by the file system watch object. I am having this problem that always at some stage new new information stops being entered into the textbox even though there should be. If I clear the textbox, new information will start tp appear again. I am not receiving any error message, so is there some sort of internal limit on the amount of text which can be added/pasted into a...
16
1460
by: Nad | last post by:
I have a very large site with valuable information. Is there any way to prevent downloading a large number of articles. Some people want to download the entire site. Any hints or pointers would be appreciated.
0
8262
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7192
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6122
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2623
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1507
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.