Re: Sharing static variables or function between source files.
- From: Jack Klein <jackklein@xxxxxxxxxxx>
- Date: Tue, 28 Nov 2006 09:45:07 -0600
On 28 Nov 2006 06:29:36 -0800, "sololoquist"
<excuse_me_who_am_i@xxxxxxxxxxx> wrote in comp.lang.c:
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
You are correct, Christopher made a mistake.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
.
- 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: Re: removing newline character from the buffer read by fgets
- Next by Date: Casting malloc (was: Reading a string of unknown size)
- 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
|
|