Re: Sharing static variables or function between source files.



You can use static var but share a pointer ( which is often a readonly
one)

For example:
a.c:
static int a = 0;
const int * p = &a;

b.c:
extern const int * p;

I use this a lot to reveal something that should be read only for other
files.

"shantanu 写道:
"
Hi,
How can we declare a static variable or function declared in one
source file, which is to be used in other source file?

.



Relevant Pages