gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Patches #219 - #224


From: Feico de Boer
Subject: Re: Patches #219 - #224
Date: Wed, 10 Apr 2002 09:40:50 +0200

----- Original Message -----
From: "Pavel Machek" <address@hidden>
To: <address@hidden>
Cc: "Pawel Kot" <address@hidden>
Sent: Monday, April 08, 2002 3:46 AM
Subject: Re: Patches #219 - #224


> >  > #224:
> >  > +#    define dump while(0)
> >  > +#    define dprintf while(0)
> >  >
> >  > Are you sure that syntax is correct?
> >
> > According to me and a co-worker that used to be in compiler design, yes
it
> > is.
> >
> > What happens:
> >     dprintf( "some format string: %s %d\n", s, n );
> > gets translated to:
> >     while(0);
>
> AFAICS it will translate to
>
> while(0)( "some format string" );
>
> That can't be right...

Both me and that co-worker overlooked the exact meaning of the argument(s)
substitution, call it stupid. :-(
However, if I look at the Cygwin GCC generated assembly code, I couldn't get
assembly from the MS compiler, you will see that the compiler completely
ignores the string argument. The compiler sees just 'while(0)' and then nows
that no code will ever be executed and doesn't generate code for it. Likely
the MS compiler does the same. Where it concers Cygwin however, GCC defines
__GNUC__ and therefor the correct defines are used for Cygwin IMHO.

So yes, it is not correct from a syntactical point of view and it seems to
work by the grace of compiler optimization. At least in this case,
optimizations are good for once. ;-) It works for now and please leave it
this way, I will try to figure out some other method that generates clean
code and no warnings.

Regards,
Feico





reply via email to

[Prev in Thread] Current Thread [Next in Thread]