Re: Sharing static variables or function between source files.
- From: "santosh" <santosh.k83@xxxxxxxxx>
- Date: 28 Nov 2006 07:59:32 -0800
sololoquist wrote:
Christopher Benson-Manica wrote:
shantanu <shantanu.sak@xxxxxxxxx> wrote:
How can we declare a static variable or function declared in one
source file, which is to be used in other source file?
1) Don't declare them to be static.
2) Add extern declarations to every source file except the one where you
define the function:
A.c
void foo() {
/* ... */
}
B.c
extern void foo;
void bar() {
/* ... */
foo();
}
How to correctly invoke your linker to make sure this works is a topic
for a different newsgroup.
Is it not necessary to make
extern void foo;
into
extern void foo();
Yes. It was probably a typo.
PS. Don't quote the sig unless you're commenting on it.
.
- References:
- Sharing static variables or function between source files.
- From: shantanu
- Re: Sharing static variables or function between source files.
- From: Christopher Benson-Manica
- Re: Sharing static variables or function between source files.
- From: sololoquist
- Sharing static variables or function between source files.
- Prev by Date: Casting malloc (was: Reading a string of unknown size)
- Next by Date: Re: removing newline character from the buffer read by fgets
- Previous by thread: Re: Sharing static variables or function between source files.
- Next by thread: Re: Sharing static variables or function between source files.
- Index(es):
Relevant Pages
|
|