extern and Static

M

Magix

Hi,

Why variable that declared Static, can not be used for extern?
example: "Static boolean test=FALSE;" declared locally.

"extern Static boolean test;" will give error.
 
J

Jonathan Adams

"Magix" <[email protected]> said:
Hi,

Why variable that declared Static, can not be used for extern?
example: "Static boolean test=FALSE;" declared locally.

"extern Static boolean test;" will give error.

Because "extern" means 'external linkage', while "static" (note the
lower-caseness) means 'internal linkage'.

So applying both to one variable would be a contradiction, and is
therefore not allowed.

Cheers,
- jonathan
 
B

Bradley Bungmunch

Hi,

Why variable that declared Static, can not be used for extern?
example: "Static boolean test=FALSE;" declared locally.

"extern Static boolean test;" will give error.

Any variable declared outside function scope has permanent duration,
if that is what you are trying to achieve - so apart from using static
illegally, there is no need for it (in the case specified).


=====================



Pussie sHaveMo
reFunMeow MeowMeowPus
siesHaveMore FunMeowMeowMeo
wPussiesHaveMo reFunMeowMeowMeo
wPussiesHaveMor eFunMeowMeowMeowP
ussiesHaveMoreFu nMeowMeowMeowPussi
esHaveMoreFunMeo wMeowMeowPussiesHav
eMoreFunMeowMeowM eowPussiesHaveMor
eFunMeowMeowMeowP ussiesHaveMoreFunM
eowMeowMeowPussie sHaveMoreFunMeowMe owMeowPus
siesHaveM oreFunMeowMeowMe owPussiesHaveMore FunMeowMeowMe
owPussiesHave MoreFunMeowMeowM eowPussiesHaveM oreFunMeowMeowM
eowPussiesHaveM oreFunMeowMeow MeowPussiesHa veMoreFunMeowMeow
MeowPussiesHave MoreFunMeow MeowMeow PussiesHaveMoreFun
MeowMeowMeowPussi esHa veMoreFunMeowMeowMe
owPussiesHaveMoreF unMeowMeowM eowPussiesHaveMoreFu
nMeowMeowMeowPussie sHaveMoreFunMe owMeowMeowPussiesHav
eMoreFunMeowMeowMeo wPussiesHaveMoreFu nMeowMeowMeowPussie
sHaveMoreFunMeowMeo wMeowPussiesHaveMoreFu nMeowMeowMeowPussi
esHaveMoreFunMeowM eowMeowPussiesHaveMoreFu nMeowMeowMeowPuss
iesHaveMoreFunMe owMeowMeowPussiesHaveMoreFu nMeowMeowMeowP
ussiesHaveMor eFunMeowMeowMeowPussiesHaveMore FunMeowMeow
MeowPussi esHaveMoreFunMeowMeowMeowPussiesHave MoreF
unMe owMeowM eowPuss
iesHave MoreF unMeowMeowM
eowPussies Ha veMoreFunMeo
wMeowMeowP us si esHaveMoreFu
nMeowMeowM eow Pus siesHaveMore
FunMeowMeo wMeow Pussi esHaveMoreFu
nMeowMeow MeowPu ssiesH aveMoreFun
Meow MeowMeow Pussie
sHaveMoreFunMeowMeowMeowPussiesHaveM
oreFunMeowMeowMeowPussiesHaveMo
reFunMeowMeowMeowPussies
 
G

gooch

Any variable declared outside function scope has permanent duration,
if that is what you are trying to achieve - so apart from using static
illegally, there is no need for it (in the case specified).


You might want to use it to hide the variable.
 
S

Starshine Moonbeam

gooch said:
Any variable declared outside function scope has permanent duration,
if that is what you are trying to achieve - so apart from using static
illegally, there is no need for it (in the case specified).


You might want to use it to hide the variable.

But you can declare a variable static and final in which case it
wouldn't be hidden but constant.

String static final MY_NAME = "starshine";

To 'hide' the variable, wouldn't you have to declare it private?
 
B

Ben Pfaff

Starshine Moonbeam said:
But you can declare a variable static and final in which case it
wouldn't be hidden but constant.

String static final MY_NAME = "starshine";

To 'hide' the variable, wouldn't you have to declare it private?

C does not have `final' or `private', nor is there anything in
the language or standard library called `String'.
 

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

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top