Re: How do I inhibit warning 528?
From: Robert (robertsadress_at_hotmail.com)
Date: 01/28/04
- Next message: James Dow Allen: "Re: integer division"
- Previous message: Dave Vandervies: "Re: unionists versus separatists"
- In reply to: CBFalconer: "Re: How do I inhibit warning 528?"
- Next in thread: Mark McIntyre: "Re: How do I inhibit warning 528?"
- Reply: Mark McIntyre: "Re: How do I inhibit warning 528?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 27 Jan 2004 22:50:46 -0800
CBFalconer <cbfalconer@yahoo.com> wrote in message news:<4016623B.3091A0FA@yahoo.com>...
> Robert wrote:
> > Emmanuel Delahaye <emdelYOURBRA@noos.fr> wrote in message
> > > In 'comp.lang.c', robertsadress@hotmail.com (Robert) wrote:
> > >
> > > > Flexelint says:
> > > >
> > > > Warning 528: Symbol 'MY_STATIC_CONST_INT_VAR' (line 426, file
> > > > headfile.h) not referenced
> > >
> > > Can you post the exact line where 'MY_STATIC_CONST_INT_VAR' is
> > > defined? Seems to be the definition of a static objet. Sounds
> > > like bad design...
> >
> > Well, I think it is bad design.
> >
> > head.h has the declaration
> > static const int MY_STATIC_CONST_INT_VAR = 3;
> >
> > file1.c, file2.c and file3.c all includes head.h
> > but only file1.c and file2.c makes use of MY_STATIC_CONST_INT_VAR.
> >
> > As I see it, there are some different ways to go.
> >
> > 1) leave it as is, never mind about a local variable that is not
> > used in file3.c.
> >
> > 2) #define MY_STATIC_CONST_INT_VAR 3 or
> > 3) #define MY_STATIC_CONST_INT_VAR (int)3
> > 4) put the declaration in one of the .c files and declare it
> > extern in the other .c files that makes use of the constant.
> >
> > I would prefer 4) as I think that gives best type checking.
> > Or are 3) as good?
> > Or is there better ways?
>
> Declare it extern in the header file (no initialization).
> Actually declare and initialize it in one of the two .c files that
> use it. There should never have been an actual data declaration
> in the .h file in the first place.
>
> Net changes: modify one line, add one line in some .c file.
But is it ok to declare it extern in the header file?
I guess that it would lead to the same situation,
that file3.c sees it as a declared but unused variable(constant).
/Robert
- Next message: James Dow Allen: "Re: integer division"
- Previous message: Dave Vandervies: "Re: unionists versus separatists"
- In reply to: CBFalconer: "Re: How do I inhibit warning 528?"
- Next in thread: Mark McIntyre: "Re: How do I inhibit warning 528?"
- Reply: Mark McIntyre: "Re: How do I inhibit warning 528?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|