Re: a basic doubt on static functions...

From: Byron A Jeff (byron_at_cc.gatech.edu)
Date: 01/27/05


Date: 27 Jan 2005 07:34:03 -0500

In article <1106827929.401971.22820@c13g2000cwb.googlegroups.com>,
shiva <nikhilbhargav_nsit@indiatimes.com> wrote:
>hello all,
>
>I have aa basic doubt about declaring function as static. What
>difference is between following two declarations
>
>static __inline__ void wait_ms(unsigned int ms);
>
>__inline__ void wait_ms(unsigned int ms);

This is really a C question which should be in comp.lang.c

static for functions changes the visibility of the function.
By default functions a visible and accessible anywhere in an
application, even if the function resides in another source file.

static limits the visibility of the function to the source file
that it's declared in.

BTW I have a unrelated question: Is there a particular reason
that certain speaker/writers of English, particularly as a
second language, use the word "doubt" in place of "question"?
It's something I've noticed over the years, and I was just curious
as to how this substitution came to be.

BAJ



Relevant Pages

  • Re: Compiler cant see class
    ... from Code Project with the same predicatable results in that I didn't ... I've also tried declaring the class object in ... Think of the compiler as reading each source file from top to bottom. ... It must encounter the #include that declares the class before it encounters any use of the class. ...
    (microsoft.public.vc.language)
  • Re: CRITICAL_SECTION not initialized globally in DllMain
    ... declaring variables in header files is a bad idea. ... In this case, the same header file being included in multiple compilation units causes multiple declarations of the same variable; unless, as when you specified static, the declarations are local scope to the compilation unit. ... > It means each source file gets it's *own* copy of the variable. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: CRITICAL_SECTION not initialized globally in DllMain
    ... What is the point of declaring a static variable if it's already global. ... Does static global not mean it's valid only in the context of the same source file? ... static CRITICAL_SECTION csCalibrate; ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Static variables.
    ... > static variable outside of the method as oppose to declaring ... appear after it in the source file, ... is visible only within func1(). ...
    (comp.lang.c)
  • Re: about a head line
    ... declaring of the encoding used in the source file. ... you might get an error like: SyntaxError: Non-ASCII ...
    (comp.lang.python)