Re: Sharing static variables or function between source files.



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.

--
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.
.



Relevant Pages