Article View: gnu.gcc.help
Article #935Re: gcc 2.7.2 warning: left-hand operand of comma expression has no effect
From: Glenn Carr
Date: Wed, 06 Mar 1996 20:13
Date: Wed, 06 Mar 1996 20:13
36 lines
1717 bytes
1717 bytes
Glenn Carr wrote:
> static char *rcsid = "$Id: cfgopen.c,v 1.4 1995/12/11 16:04:35 gcarr Exp $";
> #if __GNUC__ == 2
> #define USE(var) static void * use_##var = (&use_##var, (void *) &var)
> USE(rcsid);
> #endif
Fixed this by adding (void) before &use_##var...
#define USE(var) static void * use_##var = ((void)&use_##var, (void *) &var)
>
> We also have another frequent occurrence of this problem. We have defined a 'Dbg'
> macro as follows...
>
> void _DbgLog1(char *pszFile, int nLine, char *pszTimeFmt);
> void _DbgLog2(char *pszFmt,...);
> #ifdef DEBUG
> #define Dbg _DbgLog1(__FILE__, __LINE__, DBGLOG_TIMEFMT), _DbgLog2
> #else
> #define Dbg (void)
> #endif /* DEBUG */
>
Fixed _part_ of this problem by adding (void) before _DbgLog1...
#define DbgLog ((void)_DbgLog1(__FILE__, __LINE__, DBGLOG_TIMEFMT), _DbgLog2)
...but only when DEBUG is defined. When DEBUG is not defined, the preprocessed output
looks like this...
(void) ("The value of x is %d\n", x);
...in which case I still get the warning.
I guess (ugh) I could fall back to using Dbg(("printf args %d,%d,%d",x,y,z)),
but I really don't want to!
Technical Details
Message-ID:
<313DF1E8.7DE1@tulsa.lgc.com>Path:
arc1-ca.pugleaf.net!dildog.lgc.com!usenetReferences:
<313DEA09.237C@tulsa.lgc.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!dildog.lgc.com!usenet From: Glenn Carr <gcarr@tulsa.lgc.com> Newsgroups: gnu.gcc.help,comp.lang.c Subject: Re: gcc 2.7.2 warning: left-hand operand of comma expression has no effect Date: Wed, 06 Mar 1996 14:13:28 -0600 Organization: Landmark Graphics Message-ID: <313DF1E8.7DE1@tulsa.lgc.com> References: <313DEA09.237C@tulsa.lgc.com> NNTP-Posting-Host: 134.132.131.47 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 2.0 (X11; I; AIX 1)