Article View: comp.os.msdos.programmer
Article #2300Macro names into strings in TC 2.0
From: Evan Marshall Manning
Date: Fri, 21 Sep 1990 00:05
Date: Fri, 21 Sep 1990 00:05
69 lines
2482 bytes
2482 bytes
I'm having some trouble getting the symbols in #defined constants into
strings. It seems like what I'm doing below should work (__MSDOS__
side of #ifdef) but it gives:
The table has 2 values:
8 8
GO 0
instead of:
The table has 2 values:
MAX_AE 8
GO 0
Near as I can tell from July '90 CUJ everyone's scrambling for fancy
ways to put the value in strings & putting the symbol is what happens
when you're not careful. But it doesn't work for me.
Thanks
-- Evan
**********************************************************************
#include <stdio.h>
#ifdef __MSDOS__
#define STRINGIZE(arg) #arg
#else
#define STRINGIZE(arg) "arg"
#endif
#define MAX_AE 8
typedef enum
{
GO,
NOGO
} gonogo;
#define TBL_CONST(symbol) { STRINGIZE(symbol), symbol}
typedef struct {
char sv_symb[21];
int sv_value;
} symbol_value_type;
symbol_value_type syval[]
= {
TBL_CONST(MAX_AE),
TBL_CONST(GO)
};
#define NUM_TBL_CONST (sizeof(syval) / sizeof(syval[0]))
main (void) {
int syval_ix;
printf("The table has %d values:\n", NUM_TBL_CONST);
for ( syval_ix = 0; syval_ix < NUM_TBL_CONST; syval_ix++ ) {
printf("%20s\t%5d\n", syval[syval_ix].sv_symb,
syval[syval_ix].sv_value);
}
}
***************************************************************************
Your eyes are weary from staring at the CRT for so | Evan M. Manning
long. You feel sleepy. Notice how restful it is | is
to watch the cursor blink. Close your eyes. The |manning@gap.cco.caltech.edu
opinions stated above are yours. You cannot | manning@mars.jpl.nasa.gov
imagine why you ever felt otherwise. | gleeper@tybalt.caltech.edu
Technical Details
Message-ID:
<1990Sep21.000502.9344@nntp-server.caltech.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!jarthur!nntp-server.caltech.edu!manningShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!jarthur!nntp-server.caltech.edu!manning From: manning@nntp-server.caltech.edu (Evan Marshall Manning) Newsgroups: comp.os.msdos.programmer Subject: Macro names into strings in TC 2.0 Message-ID: <1990Sep21.000502.9344@nntp-server.caltech.edu> Date: 21 Sep 90 00:05:02 GMT Distribution: comp Organization: California Institute of Technology, Pasadena Lines: 69