By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,601 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,601 IT Pros & Developers. It's quick & easy.

i have a doubt in c programming

P: n/a
i am a beginner to comp sci field , i am a student , when i came to the
storage class specifiers area i got this doubt that is "i want to store
a variable in the register and that must be of static type" , how can i
do?
can any one help me?

Apr 19 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
raajagopal.v wrote:

I'm afraid I found you question unclear
[i] am a beginner to comp sci field , i am a student , when i came to the
storage class specifiers area i got [a question] that is "i want to store
a variable in the register
which register? Do you mean a CPU register or what?
and that must be of static type" , how can i
do? can any one help me?


If you talking about C then there is register and static keywords.
register
is pretty much unused (and useless) modern compilers manage better
without it.

So do you want a "static" "register" variable"? Why?
--
Nick Keighley

Apr 19 '06 #2

P: n/a
raajagopal.v wrote:
i am a beginner to comp sci field , i am a student , when i came to the
storage class specifiers area i got this doubt that is "i want to store
a variable in the register and that must be of static type" , how can i
do?
can any one help me?


Questions of terminology are easily answered by consulting
specialist dictionaries like "The Computer Contradictionary"
compiled by Stan Kelly-Bootle:

beta adj. (Of a software version) the one that ships.

==> Originally, beta software was sent only to volunteer
testers who had signed a nondisclosure agreement (NDA).
Unfortunately, most such volunteers had previously signed
disclosure agreements with a competitor. See also ALPHA.

Following the cross-reference:

alpha adj. (Of a version) being the first (and invariably
the best) of a series expected to converge to a usable
product.

==> Owing, inter alia, to the sad decline in classical
language skills, the series never progresses to the
Johannine limit of perfection at omega. Indeed, versions
beyond gamma are rarely encountered, since Marketing
traditionally loses patience with QA and ships the BETA.

--
Eric Sosman
es*****@acm-dot-org.invalid
Apr 19 '06 #3

P: n/a

Nick Keighley wrote:
raajagopal.v wrote:

I'm afraid I found you question unclear
[i] am a beginner to comp sci field , i am a student , when i came to the
storage class specifiers area i got [a question] that is "i want to store
a variable in the register
which register? Do you mean a CPU register or what?
and that must be of static type" , how can i
do? can any one help me?


If you talking about C then there is register and static keywords.
register is pretty much unused (and useless) modern compilers
manage better without it.


In case Nick is on the right track:

You can use `register` keyword to *suggest* to the compiler that it
should use a CPU register for a variable. However, wheter this happens
is entirely up to the compiler. <OT>If you're using an embedded
implementation it may define non-standard ways of forcing variables
into registers (even specific registers). Look it up in your
documentation.</OT>
So do you want a "static" "register" variable"? Why?


Good question. I'd imagine it to be difficult to guarantee that
functions outside the compilation unit to which a register variable is
static does not use the same register for something else.

OP, can you try and frame a better question?

Apr 19 '06 #4

P: n/a
Eric Sosman wrote:
raajagopal.v wrote:
i am a beginner to comp sci field , i am a student , when i came to the
storage class specifiers area i got this doubt that is "i want to store
a variable in the register and that must be of static type" , how can i
do?
can any one help me?

Questions of terminology are easily answered [...]


I'm not sure how I managed to attach this reply to
raajagopal.v's message; it was supposed to have been a
response to riku's question entitled BETA. Sorry for
the slip-up.

--
Eric Sosman
es*****@acm-dot-org.invalid
Apr 19 '06 #5

P: n/a
Eric Sosman wrote:
raajagopal.v wrote:
i am a beginner to comp sci field , i am a student , when i came to the
storage class specifiers area i got this doubt that is "i want to store
a variable in the register and that must be of static type" , how can i
do?
can any one help me?


Questions of terminology are easily answered by consulting
specialist dictionaries like "The Computer Contradictionary"
compiled by Stan Kelly-Bootle:

beta adj. (Of a software version) the one that ships.

==> Originally, beta software was sent only to volunteer
testers who had signed a nondisclosure agreement (NDA).
Unfortunately, most such volunteers had previously signed
disclosure agreements with a competitor. See also ALPHA.

Following the cross-reference:

alpha adj. (Of a version) being the first (and invariably
the best) of a series expected to converge to a usable
product.

==> Owing, inter alia, to the sad decline in classical
language skills, the series never progresses to the
Johannine limit of perfection at omega. Indeed, versions
beyond gamma are rarely encountered, since Marketing
traditionally loses patience with QA and ships the BETA.


I think you meant to post this in the thread entitled "BETA".

Robert Gamble

Apr 19 '06 #6

P: n/a
raajagopal.v wrote:
i am a beginner to comp sci field , i am a student , when i came to the
storage class specifiers area i got this doubt that is "i want to store
a variable in the register and that must be of static type" , how can i
do?
can any one help me?

Variables with static storage class are defined and initialized before
program startup. They exist throughout the execution of the program.

Variables declared register have automatic storage class. Also
'register' is considered only as a clue to the compiler, not a
directive. I've heard that most compilers actually ignore it. If you tried..

static register int var;

...with my compiler you get..

sr.c:4: multiple storage classes in declaration of `var'
sr.c:4: register name not specified for `var'

You can't do it on my system.

Also, sentences begin with a capital letter. The personal pronoun is I.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Apr 19 '06 #7

P: n/a
Joe Wright wrote:

raajagopal.v wrote:
i am a beginner to comp sci field , i am a student ,
when i came to the
storage class specifiers area i got this doubt that
is "i want to store
a variable in the register and that must be of static type" ,
how can i
do?
can any one help me?
Variables with static storage class are defined and initialized before
program startup. They exist throughout the execution of the program.

Variables declared register have automatic storage class. Also
'register' is considered only as a clue to the compiler, not a
directive. I've heard that most compilers actually ignore it.


The register keyword has some guaranteed effects:
1 Automatic duration, as you mention, which means that
you can't declare objects as "static register"
2 Disqualifies the register declared identifier
from being an operand of the address operator.
If you tried..

static register int var;

..with my compiler you get..

sr.c:4: multiple storage classes in declaration of `var'
sr.c:4: register name not specified for `var'

You can't do it on my system.


No surprises there.

Since OP used the phrase "storage class specifier",
I assume that he means to use the register keyword
in a declaration,
and is not using the word "register" in a more general sense.

--
pete
Apr 20 '06 #8

P: n/a
Joe Wright wrote:
raajagopal.v wrote:
<snip>
when i came to the
storage class specifiers area i got this doubt that is "i want to store
a variable in the register and that must be of static type" , how can i
do?


<snip>
Variables with static storage class are defined and initialized before
program startup. They exist throughout the execution of the program.

Variables declared register have automatic storage class.


ie. are *not* static

<snip>

Apr 21 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.