Re: Is there a real need to use keyword static with functions?
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Tue, 06 Mar 2007 17:42:45 -0500
Bill Pursell wrote:
.... snip ...
Not quite true: if you have are building a library, you may have
functions in different translation units that you want to be
accessible from all functions within the library, but not visible
outside the library. Declaring such functions static would limit
their scope to the containing translation unit. In this case,
you need to use other "linker magic" to hide the symbols.
Very simple:
/* file a.c */
#include "a.h"
#include "alocals.h"
int foo(void) { /* foocode */ }
int bar(void) { /* barcode */ }
/* file a.h */
int foo(void);
/* file alocals.h */
int bar(void);
/* file library.h */
#include "a.h"
The linker doesn't matter.
--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
.
- Follow-Ups:
- Re: Is there a real need to use keyword static with functions?
- From: Bill Pursell
- Re: Is there a real need to use keyword static with functions?
- From: Flash Gordon
- Re: Is there a real need to use keyword static with functions?
- References:
- Is there a real need to use keyword static with functions?
- From: lcdgoncalves
- Re: Is there a real need to use keyword static with functions?
- From: user923005
- Re: Is there a real need to use keyword static with functions?
- From: Bill Pursell
- Is there a real need to use keyword static with functions?
- Prev by Date: Inconsistent Program Results
- Next by Date: Re: Finding 1000 largest numbers from a file having some billion numbers
- Previous by thread: Re: Is there a real need to use keyword static with functions?
- Next by thread: Re: Is there a real need to use keyword static with functions?
- Index(es):
Relevant Pages
|