9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] compiling error
@ 2007-03-14  6:38 Gabriel Díaz
  2007-03-14  7:21 ` Skip Tavakkolian
  2007-03-14  9:44 ` matt
  0 siblings, 2 replies; 6+ messages in thread
From: Gabriel Díaz @ 2007-03-14  6:38 UTC (permalink / raw)
  To: 'Fans of the OS Plan 9 from Bell Labs'

Hello

In the following sample, why the commented print gives a syntax error?
cpu% 8c -FVw t.c
t.c:12 syntax error, last name: maxarg2


#include <u.h>
#include <libc.h>


static double maxarg1,maxarg2;
#define FMAX(a,b)
(maxarg1=(a),maxarg2=(b),(maxarg1)>(maxarg2)?(maxarg1):(maxarg2));

void main(void){
	float a,b,c,d;
	a=1.0; b=2.0; c=3.0; 
	d=FMAX(b,1.0);
	// print("%f", fabs(a)*FMAX(b,1.0)/c);
	print("%f", fabs(a)*d/c);
}


Thanks

Gabi




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] compiling error
  2007-03-14  6:38 [9fans] compiling error Gabriel Díaz
@ 2007-03-14  7:21 ` Skip Tavakkolian
  2007-03-14  7:47   ` Gabriel Díaz
  2007-03-14  9:44 ` matt
  1 sibling, 1 reply; 6+ messages in thread
From: Skip Tavakkolian @ 2007-03-14  7:21 UTC (permalink / raw)
  To: 9fans

> cpu% 8c -FVw t.c
> t.c:12 syntax error, last name: maxarg2

i get the error in a different place.
% 8c -FVw t.c
t.c:7 syntax error, last name: maxarg1

> #define FMAX(a,b)
> (maxarg1=(a),maxarg2=(b),(maxarg1)>(maxarg2)?(maxarg1):(maxarg2));

the problem is the macro. adding a \ to escape \n or putting
the macro def on the same line fixes it.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [9fans] compiling error
  2007-03-14  7:21 ` Skip Tavakkolian
@ 2007-03-14  7:47   ` Gabriel Díaz
  2007-03-14  8:20     ` Skip Tavakkolian
  0 siblings, 1 reply; 6+ messages in thread
From: Gabriel Díaz @ 2007-03-14  7:47 UTC (permalink / raw)
  To: 'Fans of the OS Plan 9 from Bell Labs'

Hello

That \n was inserted by this "intelligent" email client sorry.

The code compiles unless you uncomment the // print("%f",
fabs(a)*FMAX(b,1.0)/c);

Thanks

Gabi


-----Mensaje original-----
De: 9fans-bounces+gabidiaz=gmail.com@cse.psu.edu
[mailto:9fans-bounces+gabidiaz=gmail.com@cse.psu.edu] En nombre de Skip
Tavakkolian
Enviado el: miércoles, 14 de marzo de 2007 8:22
Para: 9fans@cse.psu.edu
Asunto: Re: [9fans] compiling error

> cpu% 8c -FVw t.c
> t.c:12 syntax error, last name: maxarg2

i get the error in a different place.
% 8c -FVw t.c
t.c:7 syntax error, last name: maxarg1

> #define FMAX(a,b)
> (maxarg1=(a),maxarg2=(b),(maxarg1)>(maxarg2)?(maxarg1):(maxarg2));

the problem is the macro. adding a \ to escape \n or putting
the macro def on the same line fixes it.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [9fans] compiling error
  2007-03-14  7:47   ` Gabriel Díaz
@ 2007-03-14  8:20     ` Skip Tavakkolian
  2007-03-14  8:32       ` Gabriel Díaz
  0 siblings, 1 reply; 6+ messages in thread
From: Skip Tavakkolian @ 2007-03-14  8:20 UTC (permalink / raw)
  To: 9fans

> The code compiles unless you uncomment the // print("%f",
> fabs(a)*FMAX(b,1.0)/c);

it's still because of the macro: the ';' at the end



^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [9fans] compiling error
  2007-03-14  8:20     ` Skip Tavakkolian
@ 2007-03-14  8:32       ` Gabriel Díaz
  0 siblings, 0 replies; 6+ messages in thread
From: Gabriel Díaz @ 2007-03-14  8:32 UTC (permalink / raw)
  To: 'Fans of the OS Plan 9 from Bell Labs'

Oh!!!!

Thank you very much, i'm off to buy a new glasses :)

Gabi


-----Mensaje original-----
De: 9fans-bounces+gabidiaz=gmail.com@cse.psu.edu
[mailto:9fans-bounces+gabidiaz=gmail.com@cse.psu.edu] En nombre de Skip
Tavakkolian
Enviado el: miércoles, 14 de marzo de 2007 9:20
Para: 9fans@cse.psu.edu
Asunto: RE: [9fans] compiling error

> The code compiles unless you uncomment the // print("%f",
> fabs(a)*FMAX(b,1.0)/c);

it's still because of the macro: the ';' at the end



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] compiling error
  2007-03-14  6:38 [9fans] compiling error Gabriel Díaz
  2007-03-14  7:21 ` Skip Tavakkolian
@ 2007-03-14  9:44 ` matt
  1 sibling, 0 replies; 6+ messages in thread
From: matt @ 2007-03-14  9:44 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

cpp is your friend

cat | cpp -P << EOF
static double maxarg1,maxarg2;
#define FMAX(a,b) 
(maxarg1=(a),maxarg2=(b),(maxarg1)>(maxarg2)?(maxarg1):(maxarg
2));
void main(void){
        float a,b,c,d;
        a=1.0; b=2.0; c=3.0;
        d=FMAX(b,1.0);
        print("%f", fabs(a)*FMAX(b,1.0)/c);
}
EOF

static double maxarg1,maxarg2;
void main(void){
        float a,b,c,d;
        a=1.0; b=2.0; c=3.0;
        
d=(maxarg1=(b),maxarg2=(1.0),(maxarg1)>(maxarg2)?(maxarg1):(maxarg2));;
        print("%f", 
fabs(a)*(maxarg1=(b),maxarg2=(1.0),(maxarg1)>(maxarg2)?(maxarg1):(maxarg2));/c);
}




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-03-14  9:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-14  6:38 [9fans] compiling error Gabriel Díaz
2007-03-14  7:21 ` Skip Tavakkolian
2007-03-14  7:47   ` Gabriel Díaz
2007-03-14  8:20     ` Skip Tavakkolian
2007-03-14  8:32       ` Gabriel Díaz
2007-03-14  9:44 ` matt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).