473,323 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

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 1894
macluvitch <ma********@hotmail.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)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #2
"macluvitch" <ma********@hotmail.com> wrote in message news:<8f******************************@localhost.t alkaboutprogramming.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********@hotmail.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 "Constraints."

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*****@inspire.net.nz> scribbled the following:
jj*@bcs.org.uk (J. J. Farrell) wrote:
"macluvitch" <ma********@hotmail.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.helsinki.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*****@inspire.net.nz> wrote in message
news:84**************************@posting.google.c om...
jj*@bcs.org.uk (J. J. Farrell) wrote:
"macluvitch" <ma********@hotmail.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*****@earthlink.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
Sorry teacher :)
I meant by ie: ? (For example)
A coherent example that shows the use of a register variable
did u anderstand ?

Nov 14 '05 #11
On Thu, 06 May 2004 09:22:03 -0400, in comp.lang.c , "macluvitch"
<ma********@hotmail.com> wrote:
Sorry teacher :)
I meant by ie: ? (For example)
A coherent example that shows the use of a register variable
Perhaps there isn't one, in these days of optimising compilers.
did u anderstand ?


if you wrote in less opaque english, people might find it easier to
understand. For instance and stating what you want instead of using
abbreviations and hoping everyone can read your mind. I'm not being funny,
but most people here have busy lives and don't have time to second-guess
the true intentions of newbies.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #12
macluvitch said the following, on 05/06/04 09:22:
Sorry teacher :)
I meant by ie: ? (For example)
A coherent example that shows the use of a register variable
did u anderstand ?


Well, you are writing not only cryptically, but also incorrectly. The
abbreviation, "i.e.", is for Latin "id est", or "that is" in English.

The equivalent "for example" abbreviation is "e.g.", for Latin "exempli
gratia" (for [the sake of] example).

If you want someone to answer your questions, it is in your interest not
to write in riddles. Besides, how difficult is it to write, "Could you
please give an example?"
--
Rich Gibbs
rg****@his.com
Nov 14 '05 #13
"macluvitch" <ma********@hotmail.com> writes:
Sorry teacher :)
I meant by ie: ? (For example)
A coherent example that shows the use of a register variable
did u anderstand ?


This was in response to something posted about 4 days ago. You can't
reasonably expect us to remember the context. It's seldom necessary
to quote the entire article to which you're responding (unless it's
fairly short), but it's very helpful to provide *some* context.

(Incidentally, "i.e." means "that is" (Latin "id est"); "e.g." means
"for example" (Latin "exempli gratia").)

This is an international forum. We do use some jargon here, but
you'll find it much easier to communicate if you write in complete
words and complete sentences. The use of 'u' rather than 'you' is
particularly frowned upon, for reasons I won't get into.

In response to what I think your actual question was, there's probably
no good use these days for register variables. The original intent of
the "register" keyword was to provide a hint to the compiler that a
given variable is going to be used heavily, and that it would be
beneficial to store it in a CPU register rather than in main memory
(and that its address will never be taken). Modern compilers are
likely to be able to figure this out for themselves; you'll get a much
better performance improvement by adding "-O3" or equivalent to your
compiler's command line than by tweaking the source. The common
wisdom is that adding "register" keywords is more likely to hinder the
compiler's optimization than to help it; I don't know how accurate
that is.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 14 '05 #14
since this moment I'll write
Thank you all folks rather than this cryptic one
Tanq u AlL Fallcks :)

Sorry for all troubles here
Nov 14 '05 #15

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

Similar topics

12
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...
10
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...
13
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...
14
by: aruna | last post by:
What is the disadvantage of using register storage class specifier?
9
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
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
by: sanchana | last post by:
how can i check whether a register variable is assigned to a register only or not
29
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
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) {...
26
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.