From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zack Weinberg To: Byron Stanoszek Cc: Geoff Keating , gcc@gcc.gnu.org Subject: Re: warning: pasting would not give a valid preprocessing token Date: Fri, 11 Aug 2000 23:31:00 -0000 Message-id: <20000811233046.A18374@wolery.cumb.org> References: X-SW-Source: 2000-08/msg00275.html On Fri, Aug 11, 2000 at 11:58:11PM -0400, Byron Stanoszek wrote: > On 11 Aug 2000, Geoff Keating wrote: > > > Byron Stanoszek writes: > > > > > I've seen this warning in many of my .c files when compiling > > > with versions of 2.96 from mid-july and newer.. has anyone else > > > seen this before, know what it is, and how to fix it? > > > > > > warning: pasting would not give a valid preprocessing token > > > > It means you're writing something like > > > > #define paste(a, b) a##b > > paste(*,foo) > > > > because '*foo' is not a token, the tokens you want are '*' and 'foo'. > > The solution is to replace the ## with a space. > > Strange, but true. I see the problem now. I have a #define like this: > > /* tprintf(): prints to a temporary variable 16k in size */ > extern char global_buff[16384]; > #define tprintf(format, args...) (sprintf(global_buff, format, ## args), \ > (char *)global_buff) > > But in my .c file, I use string concatenation like this: > > notify(player, tprintf("Your knowledge of %s is too low to speak " > "it fluently.", language[ptr->num].name)); > > Can you tell me what the best way there is to get around that? Very recent versions of gcc should not give that warning for the specific case of , ## . You could also write your tprintf() macro like this: #define tprintf(args...) (snprintf(buff, BUFSIZ, args), (char *)buff) you'll still get an error for tprintf(/* nothing */) but tprintf("string") will be fine. zw