i have a doubt in c programming

R

raajagopal.v

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?
 
N

Nick Keighley

raajagopal.v wrote:

I'm afraid I found you question unclear
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?
 
E

Eric Sosman

raajagopal.v said:
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.
 
V

Vladimir S. Oka

Nick said:
raajagopal.v wrote:

I'm afraid I found you question unclear
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. said:
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?
 
E

Eric Sosman

Eric said:
raajagopal.v said:
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.
 
R

Robert Gamble

Eric said:
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
 
J

Joe Wright

raajagopal.v said:
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.
 
P

pete

Joe said:
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.
 
N

Nick Keighley

Joe said:
raajagopal.v wrote:

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top