🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #41580

String Cat using preprocessing

#41580
From: Wen Wang
Date: Wed, 13 Mar 1996 00:00
27 lines
973 bytes
The following prog is not working using gcc, any suggestion?

#include <stdio.h>

/* try to cat two string together using preprocessor */
#define CAT(a,b) \a\b

main()
{
   int var_p;

   var_p = 900;

   printf( "%d", CAT(var_,p) );
}


looks like the gcc adds extra blank after var_ and p when expanding the CAT.

plus, if I use
 
   printf( "%d", CAT(var_, p ) )

the preprocessor will copy the leading blank of p to expand CAT.
I am expecting it to skip the leading blank as a white char.

Please email me your comments. Thanks.
Technical Details
Message-ID: <4i6rmb$oop@ringding.cs.umd.edu>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,e5ef9f965f4069d5,start
X-Google-Attributes: gid11318c,public
From: wen@cs.umd.edu (Wen Wang)
Subject: String Cat using preprocessing
Date: 1996/03/13
Message-ID: <4i6rmb$oop@ringding.cs.umd.edu>
X-Deja-AN: 142475413
distribution: world
organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
newsgroups: gnu.gcc.help