Re: Sharing static variables or function between source files.
- From: "sololoquist" <excuse_me_who_am_i@xxxxxxxxxxx>
- Date: 28 Nov 2006 06:29:36 -0800
Christopher Benson-Manica wrote:
shantanu <shantanu.sak@xxxxxxxxx> wrote:Is it not necessary to make
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.
--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
extern void foo;
into
extern void foo();
are the parenthesis unnecessary when used with extern like for an array
the size ??
please elaborate. thanx
.
- Follow-Ups:
- Re: Sharing static variables or function between source files.
- From: Christopher Benson-Manica
- Re: Sharing static variables or function between source files.
- From: santosh
- Re: Sharing static variables or function between source files.
- From: Jack Klein
- Re: Sharing static variables or function between source files.
- References:
- Sharing static variables or function between source files.
- From: shantanu
- Re: Sharing static variables or function between source files.
- From: Christopher Benson-Manica
- Sharing static variables or function between source files.
- Prev by Date: Re: Urgently required
- Next by Date: Re: Most Interesting Bug Track Down
- 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
|
|