| delorie.com/archives/browse.cgi | search |
| X-Authentication-Warning: | delorie.com: mailnull set sender to djgpp-bounces using -f |
| From: | Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: parsing errors |
| Date: | 18 Mar 2002 11:19:06 GMT |
| Organization: | Aachen University of Technology (RWTH) |
| Lines: | 45 |
| Message-ID: | <a74ifa$io8$1@nets3.rz.RWTH-Aachen.DE> |
| References: | <3C94FA1B DOT 8E6A9BA3 AT roosnek DOT nl> <Xns91D4B9FE663Basu1cornelledu AT 132 DOT 236 DOT 56 DOT 8> |
| NNTP-Posting-Host: | acp3bf.physik.rwth-aachen.de |
| X-Trace: | nets3.rz.RWTH-Aachen.DE 1016450346 19208 137.226.32.75 (18 Mar 2002 11:19:06 GMT) |
| X-Complaints-To: | abuse AT rwth-aachen DOT de |
| NNTP-Posting-Date: | 18 Mar 2002 11:19:06 GMT |
| Originator: | broeker@ |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
A. Sinan Unur <asu1 AT cornell DOT edu> wrote:
[...]
> w.c:175:4: warning: pasting "new_alpha" and "[" does not give a valid
> preprocessing token
[...]
> #define create_priori_angle( phi ) \
> new_##phi##[0]=phi##[0]+phi##[1]*delt;\
> new_##phi##[1]=phi##[1];\
> P_##phi##[0]+=.0001*delt;P_##phi##[2]+=.001*delt
> that just looks weird to me.
It's not just weird, it's plain wrong. GCC is correct to warn about this.
> why not use:
> #define create_priori_angle( phi ) \
> new_##phi[0]=phi[0]+phi[1]*delt; \
> new_##phi[1]=phi[1];\
> P_##phi[0]+=.0001*delt;P_##phi[2]+=.001*delt
That's the correct way of doing this, indeed. A slight improvement
would be:
#define create_priori_angle( phi ) do {\
new_##phi[0]=phi[0]+phi[1]*delt; \
new_##phi[1]=phi[1];\
P_##phi[0]+=.0001*delt;
P_##phi[2]+=.001*delt;
} while(0)
This will allow things like
if (condition)
create_priori_angle(alpha);
else
create_priori_angle(beta);
to do what you thought they would, without restricting you to always
place { }.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |