On 7/25/07, Tulip Rasputin <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have a function, foo(), defined in a file a.c which defines and uses a
> variable named xxx. Now i have another function, bar(), defined in some
> other file, b.c, which also uses a static variable named xxx. Now foo()
> calls bar() and both manupilate xxx. Can something go wrong here?
>
> The two functions foo() and bar() go something like this:
>
> func foo() /* defined in a.c */
> {
> int xxx = 0;
>
> bar(&xxx);
>
> /* Some more processing is done on xxx */
>
> printf ("%d\n", xxx)
> }
>
> bar (int *yyy) /* defined in b.c */
> {
> int z = xxx; /* xxx is a static variable defined in the file b.c */
>
> /* Do some Processing on z */
>
> *yyy = z;
> }
>
> Any help in this regard would be really appreciated.
>
> Thanks,
> Tulip
>
> Get a sneak peak at messages with a handy reading pane with All new Yahoo!
> Mail: http://mrd.mail.yahoo.com/try_beta?.intl=ca
>
>
Declaring a variable static in b.h would not make the variable accessible
outside b.h. So even if you include b.h in some other file a.h, then its
legal to have a variable with same name.
As pointed by Nico, its not good to employ such coding practices... you can
think of namespace if you cannot avoid the use case.
--
Regards
Sumit Chawla ("eNetra : Hail the Invention")
"Computers are useless. They can only give you answers.":Pablo Picasso
[Non-text portions of this message have been removed]