473,788 Members | 2,706 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

register variable

Hello folks

I often use register variables within functions (or as funcion parameters)
that reauired speed like searching for example . I know that it doesn't
mean that every register variable will be holded in register

so is there any rules to precize when using them
thanks

Nov 14 '05 #1
14 1924
macluvitch <ma********@hot mail.com> spoke thus:
I often use register variables within functions (or as funcion parameters)
that reauired speed like searching for example . I know that it doesn't
mean that every register variable will be holded in register


Short answer: You're probably wasting your time, at best.

Long answer: Look a few threads down for the latest discussion of the
register keyword.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #2
"macluvitch " <ma********@hot mail.com> wrote in message news:<8f******* *************** ********@localh ost.talkaboutpr ogramming.com>. ..
Hello folks

I often use register variables within functions (or as funcion parameters)
that reauired speed like searching for example . I know that it doesn't
mean that every register variable will be holded in register

so is there any rules to precize when using them


Yes - use them only when you want to prevent the code taking the address
of the variable.
Nov 14 '05 #3
ie: ?
Nov 14 '05 #4

On Sun, 2 May 2004, macluvitch wrote:

ie: ?


You've just posted three messages in a row like this: no context,
no content (at least, not in English). Consider forming a coherent
sentence or two. Make sure your readers know what you're talking
about. Quote context if it's necessary to your point. Google
"Usenet FAQ" if you don't know how to post to newsgroups; it's worth
your while.

FWIW, the '?' operator in C has nothing to do with the 'register'
keyword.

-Arthur
Nov 14 '05 #5
jj*@bcs.org.uk (J. J. Farrell) wrote:
"macluvitch " <ma********@hot mail.com> wrote:
Hello folks

I often use register variables within functions (or as funcion parameters)
that reauired speed like searching for example . I know that it doesn't
mean that every register variable will be holded in register

so is there any rules to precize when using them


Yes - use them only when you want to prevent the code taking the address
of the variable.


The register keyword does not prevent code taking the address of the
variable. It is only an optimisation hint.
Nov 14 '05 #6
Old Wolf wrote:
The register keyword does not prevent code taking the address of the
variable. It is only an optimisation hint.


You are mistaken. Notice the word "Constraint s."

6.5.3.2 Address and indirection operators

Constraints

The operand of the unary & operator shall be either a
function designator, the result of a [] or unary * operator,
or an lvalue that designates an object that is not a bit-
field and is not declared with the register storage-class
specifier.
Nov 14 '05 #7
Old Wolf <ol*****@inspir e.net.nz> scribbled the following:
jj*@bcs.org.uk (J. J. Farrell) wrote:
"macluvitch " <ma********@hot mail.com> wrote:
> Hello folks
>
> I often use register variables within functions (or as funcion parameters)
> that reauired speed like searching for example . I know that it doesn't
> mean that every register variable will be holded in register
>
> so is there any rules to precize when using them
Yes - use them only when you want to prevent the code taking the address
of the variable.

The register keyword does not prevent code taking the address of the
variable. It is only an optimisation hint.


If it didn't prevent code from taking the address of the variable, then
how would the compiler ever manage to optimise code that does take the
address of the variable?

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Keep shooting, sooner or later you're bound to hit something."
- Misfire
Nov 14 '05 #8

"Old Wolf" <ol*****@inspir e.net.nz> wrote in message
news:84******** *************** ***@posting.goo gle.com...
jj*@bcs.org.uk (J. J. Farrell) wrote:
"macluvitch " <ma********@hot mail.com> wrote:
Hello folks

I often use register variables within functions (or as funcion parameters) that reauired speed like searching for example . I know that it doesn't mean that every register variable will be holded in register

so is there any rules to precize when using them


Yes - use them only when you want to prevent the code taking the address
of the variable.


The register keyword does not prevent code taking the address of the
variable. It is only an optimisation hint.


Tell that to the Standard.

Nov 14 '05 #9
Martin Ambuhl <ma*****@earthl ink.net> wrote:
Old Wolf wrote:
The register keyword does not prevent code taking the address of the
variable. It is only an optimisation hint.


You are mistaken.>
The operand of the unary & operator shall be either a
function designator, the result of a [] or unary * operator,
or an lvalue that designates an object that is not a bit-
field and is not declared with the register storage-class
specifier.


ACK. I should know by now not to go by what some compilers (even in
strict c99 mode) will accept.
Nov 14 '05 #10

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

Similar topics

12
2255
by: Ioannis Vranos | last post by:
Just some thought on it, wanting to see any explanations. It was advised in this newsgroups that we should avoid the use of keyword register. However it is a language feature, and if it offers no help to an implementation, it is free to ignore it. And this happens widely, all my C++ compilers in my platform ignore this keyword.
10
15663
by: ajay | last post by:
some say floats can't be stored in register. size of int and float are same ( on some machine am i Wrong?) so if int can be delcared as register than why not float(where in and float are of same size) ? tx Ajay
13
6211
by: Shankar Agarwal | last post by:
I was trying to use a variable whose value is temporary and i don't want it to go to the memory for performance reasons. Is there a way to specify the variable like that so that any assignment to the variable does not go to memory. I tried the type register but it does not seem to work. Thanks Shankar
14
7916
by: aruna | last post by:
What is the disadvantage of using register storage class specifier?
9
8612
by: Jackie | last post by:
Hi everyone, Does anyone know when "register" declarations should be used and when "register" must not be used? If possible please give examples for both cases. Thanks
16
2466
by: junky_fellow | last post by:
what is the purpose of declaring a register variable ? why can't we find the address of register variable ?
4
1455
by: sanchana | last post by:
how can i check whether a register variable is assigned to a register only or not
29
2480
by: orium69 | last post by:
hi everyone, i'm wondering if there is a way to have sure that a variable is allocated in the cache, after its declaration with "register"? Tks!
7
5168
by: int main(void) | last post by:
Hi all, I know that register variables work fine at block scope. I tried putting a register variable in file scope, like this, #include <stdio.h> register int a = 2; int main(void) { printf("%d\n",a);
26
2232
by: Vashna | last post by:
Hi Group, I have a doubt about register variables. I know that if we have a variable used very frequently in a function, then provided we never apply the & function to it, we can define it as a register variable and this will make it much faster to access. Now the question is: obviously there are only a fixed number of registers in our CPU, maybe 6 or something. So how do we choose which
0
9656
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
9498
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
10370
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
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
10113
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
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5402
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...
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2896
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.