[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Pnet-developers] Bug in cscc in C mode ?
From: |
Mike Aubury |
Subject: |
Re: [Pnet-developers] Bug in cscc in C mode ? |
Date: |
Mon, 15 Mar 2004 17:04:36 +0000 |
User-agent: |
KMail/1.6.1 |
Having playing with this kind of thing before the method??varname won't work
either - consider:
.. func(..) {
if (something) {
static int a=0;
printf("my first counter=%d",a++);
}
if (somethingelse) {
static int a=0;
printf("my second counter=%d\n",a++);
}
}
Basically - you'll need to keep a track of the current block number within the
source file and/or method, and use that, rather than the method alone..
(Maybe thats what your ?? were for...)
Note - This may seem like bad coding style etc - but a lot of C is generated
automatically in one way or another, and this sort of construct isn't unusual
(think of flex/bison with statics in the actions for a prime example)..
On Monday 15 March 2004 11:21, Gopal V wrote:
> The method static variables are treated like global
> variables right now ...
>
> So they collide ...
>
> Until rhys brings something like methodname??varname
> or other naming convention .. thisll be there :)
>
> Look at the assembly generated ...
>
> Gopal
>
> --- address@hidden <address@hidden> wrote:
> > Just tried to compile this :
> >
> > main(int argc,char *argv[]) {
> > static char *f="Hello";
> > }
> >
> > int func(void) {
> > static char *f="World";
> > }
> >
> > address@hidden:~/aubit4glsrc/tools/test> cscc test.c
> > stdin:27: duplicate definition for `f'
> >
> >
> > If I remove the 'static' before the char *f - it
>
> compiles fine...
>
> > _______________________________________________
> > Pnet-developers mailing list
> > address@hidden
> > http://dotgnu.org/mailman/listinfo/pnet-developers
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - More reliable, more storage, less spam
> http://mail.yahoo.com
> _______________________________________________
> Pnet-developers mailing list
> address@hidden
> http://dotgnu.org/mailman/listinfo/pnet-developers