9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] plan9's C compiler and // comments
@ 2003-09-15  3:06 David Presotto
  2003-09-15  3:14 ` mirtchov
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: David Presotto @ 2003-09-15  3:06 UTC (permalink / raw)
  To: enache, 9fans

[-- Attachment #1: Type: text/plain, Size: 402 bytes --]

Looks like just the opposite to me.  /**/ comments are handled specially.
The prepocessor doesn't know anything about // comments.  If you want to
change it, I wouldn't mind.  I think nobody ever thought of or cared to
do it before because we frown so much on programming with the preprocessor.

The // at the end of your endif makes it through only because everything after the
endif is ignored.

[-- Attachment #2: Type: message/rfc822, Size: 2629 bytes --]

From: Enache Adrian <enache@rdslink.ro>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] plan9's C compiler and // comments
Date: Mon, 15 Sep 2003 05:21:21 +0300
Message-ID: <20030915022121.GC1290@ratsnest.hole>

> On Sun, Sep 14, 2003 a.d., David Presotto wrote:
> > It accepts it just fine.  You're just defining a macro as
> >
> > 	"wow!"	// this won't work
> >
> > and when it gets expanded in the exits you get
> >
> > void main() { exits("wow!"	// this won't work); }

Judging about what I understand of cmd/cc/macbody:237-260,
ex. the /**/ comments are not passed through macros to be dealt with
later, but discarded during the parsing of the '#define' directive.

So the handling of '//' comments is just special in this case.

Regards,
Adi

^ permalink raw reply	[flat|nested] 21+ messages in thread
[parent not found: <1630899296@snellwilcox.com>]
* [9fans] plan9's C compiler and // comments
@ 2003-09-15  1:02 David Presotto
  2003-09-15  1:16 ` Enache Adrian
  0 siblings, 1 reply; 21+ messages in thread
From: David Presotto @ 2003-09-15  1:02 UTC (permalink / raw)
  To: 9fans

It accepts it just fine.  You're just defining a macro as

	"wow!"	// this won't work

and when it gets expanded in the exits you get

void main() { exits("wow!"	// this won't work); }

which eats up the '); }' at the end of the function.


^ permalink raw reply	[flat|nested] 21+ messages in thread
* [9fans] plan9's C compiler and // comments
@ 2003-09-15  0:49 Enache Adrian
  0 siblings, 0 replies; 21+ messages in thread
From: Enache Adrian @ 2003-09-15  0:49 UTC (permalink / raw)
  To: 9fans

The C compiler accepts '//..' C++ -like comments, but not in '#define'
directives.

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

// this one OK
#ifndef FOO
#define EXITS	"wow!"	// this won't work
#endif // this one OK too

void main() { exits(EXITS); }
-----------------------

Is this deliberate behaviour ?

(sorry if it's already fixed, my plan9 is a bit out of date).

Thanks,
Adi


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

end of thread, other threads:[~2003-09-15 11:26 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-15  3:06 [9fans] plan9's C compiler and // comments David Presotto
2003-09-15  3:14 ` mirtchov
2003-09-15  3:19   ` David Presotto
2003-09-15  7:11     ` Charles Forsyth
2003-09-15  7:51   ` boyd, rounin
2003-09-15  8:23   ` boyd, rounin
2003-09-15  3:21 ` Bruce Ellis
2003-09-15  8:00   ` boyd, rounin
2003-09-15  4:06 ` Enache Adrian
2003-09-15  7:03   ` Charles Forsyth
2003-09-15  7:49 ` boyd, rounin
2003-09-15  8:01   ` Geoff Collyer
     [not found] <1630899296@snellwilcox.com>
2003-09-15 11:01 ` steve.simon
2003-09-15 11:23   ` C H Forsyth
2003-09-15 11:26   ` C H Forsyth
  -- strict thread matches above, loose matches on Subject: below --
2003-09-15  1:02 David Presotto
2003-09-15  1:16 ` Enache Adrian
2003-09-15  1:23   ` boyd, rounin
2003-09-15  7:21     ` Charles Forsyth
2003-09-15  2:21   ` Enache Adrian
2003-09-15  0:49 Enache Adrian

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).