9front - general discussion about 9front
 help / color / mirror / Atom feed
* Re: [9front] Cpp: handle c99 comments by default.
@ 2019-06-18  5:03 ori
  0 siblings, 0 replies; 2+ messages in thread
From: ori @ 2019-06-18  5:03 UTC (permalink / raw)
  To: steve, 9front

> I think the rational was that the compiler tried very hard to be c89 compliant and c89 does not
> Include c++ comments by default.
> 
> Perhaps, it should default to on for the pcc command but still default to off for the c89 command.
> The c99 command (if there ever is on would have it on too fo course…).
> 
> -Steve

I understand the intention -- but we don't disable any other extensions (struct embedding, indexed
initialization, etc) in the compiler. I'm not sure how much we care about this one either.



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

* Re: [9front] Cpp: handle c99 comments by default.
  2019-06-17 19:27 Ori Bernstein
@ 2019-06-17 22:18 ` Steve Simon
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Simon @ 2019-06-17 22:18 UTC (permalink / raw)
  To: 9front

I think the rational was that the compiler tried very hard to be c89 compliant and c89 does not
Include c++ comments by default.

Perhaps, it should default to on for the pcc command but still default to off for the c89 command.
The c99 command (if there ever is on would have it on too fo course…).

-Steve


> On 17 Jun 2019, at 20:27, Ori Bernstein <ori@eigenstate.org> wrote:
> 
> This change makes the -+ flag default in cpp, and turns it into a no-op.
> 
> C99 comments have been the default in compilers for something like 20 years
> now. This means we don't need to remember to turn it on when porting software,
> and gets rid of cryptic errors about unterminated character constants when
> someone writes something like:
> 
> 	// Didn't need to...
> 
> I didn't add a way to turn the option off. All of our software works under
> this change, and I can't imagine any place we care that // is a syntax error
> rather than a comment.
> 
> The flag itself is retained so we don't break existing mkfiles -- but maybe
> we want to remove it entirely.
> 
> diff -r 40949afe3df8 sys/src/cmd/cpp/cpp.c
> --- a/sys/src/cmd/cpp/cpp.c	Mon Jun 17 13:17:16 2019 +0930
> +++ b/sys/src/cmd/cpp/cpp.c	Mon Jun 17 12:19:36 2019 -0700
> @@ -28,7 +28,6 @@
> 	maketokenrow(3, &tr);
> 	expandlex();
> 	setup(argc, argv);
> -	fixlex();
> 	iniths();
> 	genline();
> 	process(&tr);
> diff -r 40949afe3df8 sys/src/cmd/cpp/cpp.h
> --- a/sys/src/cmd/cpp/cpp.h	Mon Jun 17 13:17:16 2019 +0930
> +++ b/sys/src/cmd/cpp/cpp.h	Mon Jun 17 12:19:36 2019 -0700
> @@ -86,7 +86,6 @@
> enum errtype { WARNING, ERROR, FATAL };
> 
> void	expandlex(void);
> -void	fixlex(void);
> void	setup(int, char **);
> #define gettokens cpp_gettokens
> int	gettokens(Tokenrow *, int);
> diff -r 40949afe3df8 sys/src/cmd/cpp/lex.c
> --- a/sys/src/cmd/cpp/lex.c	Mon Jun 17 13:17:16 2019 +0930
> +++ b/sys/src/cmd/cpp/lex.c	Mon Jun 17 12:19:36 2019 -0700
> @@ -285,14 +285,6 @@
> 	}
> }
> 
> -void
> -fixlex(void)
> -{
> -	/* do C++ comments? */
> -	if (Cplusplus==0)
> -		bigfsm['/'][COM1] = bigfsm['x'][COM1];
> -}
> -
> /*
>  * fill in a row of tokens from input, terminated by NL or END
>  * First token is put at trp->lp.
> diff -r 40949afe3df8 sys/src/cmd/cpp/nlist.c
> --- a/sys/src/cmd/cpp/nlist.c	Mon Jun 17 13:17:16 2019 +0930
> +++ b/sys/src/cmd/cpp/nlist.c	Mon Jun 17 12:19:36 2019 -0700
> @@ -8,7 +8,6 @@
> extern	int	optind;
> int	verbose;
> int	Mflag;
> -int	Cplusplus;
> int	nolineinfo;
> Nlist	*kwdefined;
> char	wd[128];
> @@ -142,7 +141,7 @@
> 			verbose++;
> 			break;
> 		case '+':
> -			Cplusplus++;
> +			/* Ignored for compatibility */
> 			break;
> 		case 'i':
> 			debuginclude++;
> diff -r 40949afe3df8 sys/src/cmd/pcc.c
> --- a/sys/src/cmd/pcc.c	Mon Jun 17 13:17:16 2019 +0930
> +++ b/sys/src/cmd/pcc.c	Mon Jun 17 12:19:36 2019 -0700
> @@ -65,7 +65,7 @@
> 	while(argc > 0) {
> 		ARGBEGIN {
> 		case '+':
> -			append(&cpp, smprint("-%c", ARGC()));
> +			/* No-op for compatibility */
> 			break;
> 		case 'c':
> 			cflag = 1;
> 
> 
> -- 
> Ori Bernstein <ori@eigenstate.org>



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

end of thread, other threads:[~2019-06-18  5:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-18  5:03 [9front] Cpp: handle c99 comments by default ori
  -- strict thread matches above, loose matches on Subject: below --
2019-06-17 19:27 Ori Bernstein
2019-06-17 22:18 ` [9front] " Steve Simon

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