🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2428

Re: Preprocessor question

#2428
From: Doug Gwyn
Date: Sun, 17 Feb 1991 20:11
16 lines
1078 bytes
In article <AHUTTUNE.91Feb16230548@silver-surfer.hut.fi> ahuttune@niksula.hut.fi (Ari Juhani Huttunen) writes:
>I would like to do the following or something similar:
>#define BLOCK_SIZE 1024
>char *message = "The block size is " # BLOCK_SIZE " bytes.";
>I need the result: "The block size is 1024 bytes."
>I know what I am doing wrong, but HOW should I do it? These alternatives
>are no good:
>	- #define BLOCK_SIZE_STRING "1024"
>	- char *message = "The block size is 1024 bytes.";

#define	STRINGIZE(x)	# x	
#define	PSTRINGIZE(x)	STRINGIZE(x)
...
#define	BLOCK_SIZE	1024
...
char	message[] = "The block size is " PSTRINGIZE(BLOCK_SIZE) " bytes.";
Technical Details
Message-ID: <15232@smoke.brl.mil>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!hsdndev!cmcl2!adm!smoke!gwyn
References: <AHUTTUNE.91Feb16230548@silver-surfer.hut.fi>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!hsdndev!cmcl2!adm!smoke!gwyn
From: gwyn@smoke.brl.mil (Doug Gwyn)
Newsgroups: comp.std.c
Subject: Re: Preprocessor question
Message-ID: <15232@smoke.brl.mil>
Date: 17 Feb 91 20:11:30 GMT
References: <AHUTTUNE.91Feb16230548@silver-surfer.hut.fi>
Organization: U.S. Army Ballistic Research Laboratory, APG, MD.
Lines: 16