Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > storage class static of functions

Reply
Thread Tools

storage class static of functions

 
 
asit
Guest
Posts: n/a
 
      01-15-2008
Can functions have static storage clas ?? If yes, what is it's
advantage ??
 
Reply With Quote
 
 
 
 
jameskuyper@verizon.net
Guest
Posts: n/a
 
      01-16-2008
Chris Dollin wrote:
> Willem wrote:
>
> > asit wrote:
> > ) Can functions have static storage clas ?? If yes, what is it's
> > ) advantage ??
> >
> > No, functions can not have static storage class.

>
> That's an interesting claim; to be clear, are you saying that
>
> static void nuffin(void) {}
>
> isn't legal, or are you saying that the notion of "storage class"
> appropriate to variables isn't applicable to functions?


The latter. It's actually referred to as "storage duration" rather
than "storage class" in the standard. The result of applying the
'static' keyword to the definition of a variable is to give that
variable static storage duration. The result of applying the 'static'
keyword to the definition of a function is to give that function's
name internal linkage.
 
Reply With Quote
 
 
 
 
Ravishankar S
Guest
Posts: n/a
 
      01-16-2008
"asit" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Can functions have static storage clas ??

yes , they can.
If yes, what is it's advantage ??
the "advantages" , if one can call that , are:

the static keyword makes the functions local to the file (more accurately
"translation unit") in which it is defined. This means the function can be
called only within that fileTherefore it
1) Provides modularity by data hiding and
2) Gives an opportunity to the compiler to optimize better (by say inlining)

In certain cases a "static" "inline" function is a type-safe replacement for
a preprocessor macro.





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: storage class static of functions Willem C Programming 2 01-15-2008 10:20 PM
Re: storage class static of functions jacob navia C Programming 2 01-15-2008 09:36 PM
Difference b/w storage class and storage class specifier sarathy C Programming 2 07-17-2006 05:06 PM
Instantiating a static class( Class with all static members - methods and variables) SaravanaKumar Java 6 10-19-2004 08:20 AM
a static local variable in a static method is thread local storage? Patrick Hoffmann C++ 3 08-08-2003 02:37 PM



Advertisments