473,395 Members | 1,496 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,395 software developers and data experts.

What is the Use Of Static Fuction.

What is the use by making function Static.

Feb 1 '06 #1
3 1824

Umesh wrote:
What is the use by making function Static.


Short answer: static functions are invisible to the other compilation
units. This means you're allowed to re-use the same function names in
other source files, and the linker won't balk at you.

I'm sure there's a more precise way of saying the above.

Cheers

Vladimir

Feb 1 '06 #2
On Wed, 01 Feb 2006 02:23:41 -0800, Vladimir S. Oka wrote:

Umesh wrote:
What is the use by making function Static.


Short answer: static functions are invisible to the other compilation
units. This means you're allowed to re-use the same function names in
other source files, and the linker won't balk at you.

I'm sure there's a more precise way of saying the above.


Maybe not more precise, but certainly simpler: A function F labeled
static can only be used by functions defined in the same file as F.
Feb 1 '06 #3
James S. Singleton wrote:
On Wed, 01 Feb 2006 02:23:41 -0800, Vladimir S. Oka wrote:

Umesh wrote:
What is the use by making function Static.


Short answer: static functions are invisible to the other compilation
units. This means you're allowed to re-use the same function names in
other source files, and the linker won't balk at you.

I'm sure there's a more precise way of saying the above.


Maybe not more precise, but certainly simpler: A function F labeled
static can only be used by functions defined in the same file as F.


/referenced by name/, not /used/:

File A:

void user( void (*arg)(void) ) { arg(); }

File B:

#include <stdio.h>

extern void user( int (*arg)(void) );

static void used() { printf( ">> 'used' called\n" ); }

int main(void)
{
user( used );
return 0;
}

A uses `used` (it calls it). It cannot refer to it by name.

--
Chris "understanding is a three-edged sword" Dollin
Feb 1 '06 #4

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

Similar topics

2
by: orion30 | last post by:
I would like to know, if an allocated variable returning by a fuction is unallocated automatically ? If no how to proceed ? Best regards ...
1
by: Szaki | last post by:
I use a BulkLoad to import file.xml to my base MS Server 2000. To import this xml file I need schema file. Mayby you know how to do this file mechanicy f.g. mayby somebody have some script in .net...
1
by: orion30 | last post by:
I would like to know, if an allocated variable returning by a fuction is unallocated automatically ? If no how to proceed ? Best regards ...
140
by: Oliver Brausch | last post by:
Hello, have you ever heard about this MS-visual c compiler bug? look at the small prog: static int x=0; int bit32() { return ++x; }
4
by: atv | last post by:
Whatis the proper way to handle errors from function calls? For example, i normally have a main function, with calls to mine or c functions. Should i check for errors in the functions called...
5
by: SemSem | last post by:
when i was usong c++ idont have to put static before tha function that i want to acces but in c# i have to but it . ex : ihave a function called add(int x,int y) i have to put static int...
3
by: mike | last post by:
i've already used static fuction to make website i wanna common module that's why i used static fuctions. may be it's more than 100 fuction ...is it ok?
1
by: rs | last post by:
I am trying to override the keypress fucntion in a form as the following Private Sub rtbInput_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles...
1
by: jacuna | last post by:
the ______ keyword is used in a fuction header to indicate that a function does not return a value or to indicate that a function cotains no parameters
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.