9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] pcc macro issue
@ 2021-01-21  5:59 Xiao-Yong Jin
  2021-01-21  6:50 ` Kurt H Maier
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Xiao-Yong Jin @ 2021-01-21  5:59 UTC (permalink / raw)
  To: 9front

The following is wrong.

cpu% cat test.c
#define N
#define F(x)
#define M F(N)
M
cpu% pcc -E test.c
cpp: test.c:4 Disagreement in number of macro arguments
#line 1 "/tmp/test.c"



 F()
pcc: cpp: cpp 25337: errors


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

* Re: [9front] pcc macro issue
  2021-01-21  5:59 [9front] pcc macro issue Xiao-Yong Jin
@ 2021-01-21  6:50 ` Kurt H Maier
  2021-01-21 10:48 ` Jonas Amoson
  2021-01-21 18:01 ` ori
  2 siblings, 0 replies; 5+ messages in thread
From: Kurt H Maier @ 2021-01-21  6:50 UTC (permalink / raw)
  To: 9front

On Wed, Jan 20, 2021 at 11:59:31PM -0600, Xiao-Yong Jin wrote:
> The following is wrong.

Only in C99. In C89 this is undefined.

khm

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

* Re: [9front] pcc macro issue
  2021-01-21  5:59 [9front] pcc macro issue Xiao-Yong Jin
  2021-01-21  6:50 ` Kurt H Maier
@ 2021-01-21 10:48 ` Jonas Amoson
  2021-01-21 17:30   ` Xiao-Yong Jin
  2021-01-21 18:01 ` ori
  2 siblings, 1 reply; 5+ messages in thread
From: Jonas Amoson @ 2021-01-21 10:48 UTC (permalink / raw)
  To: 9front

This is a distilled example. Do you have a real case where
you encountered a problem? I am no expert in C macros,
but it could be interesting to try to see.

On Thu, 21 Jan 2021 at 08:25, Xiao-Yong Jin <meta.jxy@gmail.com> wrote:
>
> The following is wrong.
>
> cpu% cat test.c
> #define N
> #define F(x)
> #define M F(N)
> M
> cpu% pcc -E test.c
> cpp: test.c:4 Disagreement in number of macro arguments
> #line 1 "/tmp/test.c"
>
>
>
>  F()
> pcc: cpp: cpp 25337: errors
>

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

* Re: [9front] pcc macro issue
  2021-01-21 10:48 ` Jonas Amoson
@ 2021-01-21 17:30   ` Xiao-Yong Jin
  0 siblings, 0 replies; 5+ messages in thread
From: Xiao-Yong Jin @ 2021-01-21 17:30 UTC (permalink / raw)
  To: 9front

https://github.com/gambit/gambit/blob/ca8b488447f78d4165f3f3064875c57424b42a3e/include/gambit.h.in#L6338-L6380

> On Jan 21, 2021, at 4:48 AM, Jonas Amoson <jonas.amoson@gmail.com> wrote:
> 
> This is a distilled example. Do you have a real case where
> you encountered a problem? I am no expert in C macros,
> but it could be interesting to try to see.
> 
> On Thu, 21 Jan 2021 at 08:25, Xiao-Yong Jin <meta.jxy@gmail.com> wrote:
>> 
>> The following is wrong.
>> 
>> cpu% cat test.c
>> #define N
>> #define F(x)
>> #define M F(N)
>> M
>> cpu% pcc -E test.c
>> cpp: test.c:4 Disagreement in number of macro arguments
>> #line 1 "/tmp/test.c"
>> 
>> 
>> 
>> F()
>> pcc: cpp: cpp 25337: errors
>> 


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

* Re: [9front] pcc macro issue
  2021-01-21  5:59 [9front] pcc macro issue Xiao-Yong Jin
  2021-01-21  6:50 ` Kurt H Maier
  2021-01-21 10:48 ` Jonas Amoson
@ 2021-01-21 18:01 ` ori
  2 siblings, 0 replies; 5+ messages in thread
From: ori @ 2021-01-21 18:01 UTC (permalink / raw)
  To: 9front

Quoth Xiao-Yong Jin <meta.jxy@gmail.com>:
> The following is wrong.
> 
> cpu% cat test.c
> #define N
> #define F(x)
> #define M F(N)
> M
> cpu% pcc -E test.c
> cpp: test.c:4 Disagreement in number of macro arguments
> #line 1 "/tmp/test.c"
> 
> 
> 
>  F()
> pcc: cpp: cpp 25337: errors
> 

Yep, I fixed a lot of problems in cpp, but this
is one that I didn't get to. Another one is
space handling, which we currently ignore.

	#define MAC(x) y

	MAC(x)	// should expand to y
	MAC (x)	// should remain untouched

ANSI C macro expansion rules are subtle and
arcane. I've got a few tests in my underwhelming
regression suite, which may help if you want
to take a stab at this:

http://shithub.us/git/ori/regress/HEAD/cmd/cpp/f.html


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

end of thread, other threads:[~2021-01-21 18:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21  5:59 [9front] pcc macro issue Xiao-Yong Jin
2021-01-21  6:50 ` Kurt H Maier
2021-01-21 10:48 ` Jonas Amoson
2021-01-21 17:30   ` Xiao-Yong Jin
2021-01-21 18:01 ` ori

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