From: Nick Owens <mischief@offblast.org>
To: 9front@9front.org
Subject: bug: cpp(1) token pasting failure
Date: Sun, 16 Sep 2018 13:54:16 -0700 [thread overview]
Message-ID: <CAH_zEu5vejwg0OzoTGP-iz+f5+dhL42m=hzo5+tkM+T4KcUQGQ@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1100 bytes --]
the attached C program will fail to be preprocessed by cpp(1) with the
following output. for comparison, the gcc -E test.c output follows as
well. this specific example was extracted from tinycc.
9front cpp(1):
term% cpp concat.c
cpp: concat.c:8 Bad token jo) produced by ##
cpp: concat.c:8 No newline at end of file
cpp: concat.c:8 EOF in macro arglist
cpp: concat.c:8 Disagreement in number of macro arguments
#line 1 "/usr/glenda/code/c/trash/concat.c"
#line 4 "/usr/glenda/code/c/trash/concat.c"
enum token {
TOK_NULL
DEF_ASM(jo #undef DEF};static const char keywords[] = #define DEF(id,
str) str "\0" DEF_ASMTEST(j,)#undef DEF;int main(int argc, char
*argv[]){ return -1;}#line 23
"/usr/glenda/code/c/trash/concat.c"
gcc -E:
mischief@omicron:/tmp $ gcc -E concat.c
# 1 "concat.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "concat.c"
enum token {
TOK_NULL
,TOK_ASM_jo
};
static const char keywords[] =
"jo" "\0"
;
int
main(int argc, char *argv[])
{
return 0;
}
[-- Attachment #2: concat.c --]
[-- Type: text/x-csrc, Size: 356 bytes --]
#define DEF_ASM(x) DEF(TOK_ASM_ ## x, #x)
#define DEF_ASMTEST(x,suffix) \
DEF_ASM(x ## o ## suffix)
enum token {
TOK_NULL
#define DEF(id, str) ,id
DEF_ASMTEST(j,)
#undef DEF
};
static const char keywords[] =
#define DEF(id, str) str "\0"
DEF_ASMTEST(j,)
#undef DEF
;
#define DEF(id, str)
int
main(int argc, char *argv[])
{
return 0;
}
next reply other threads:[~2018-09-16 20:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-16 20:54 Nick Owens [this message]
2018-09-17 10:17 ` [9front] " Ethan Gardener
2018-09-17 11:53 ` Nick Owens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAH_zEu5vejwg0OzoTGP-iz+f5+dhL42m=hzo5+tkM+T4KcUQGQ@mail.gmail.com' \
--to=mischief@offblast.org \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).