Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Oct 1995 23:04:39 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        hackers@freefall.freebsd.org, hsu@freefall.freebsd.org
Subject:   Re: cpp question
Message-ID:  <199510271304.XAA13158@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>Well, if you use gcc -E or an ANSI cpp, you can use #name.

If you use a 4.4BSD derived system, then you can #include
<sys/cdefs.h> (perhaps indirectly) and use __STRING(), which is
supposed to hide the unportability of #name.  Don't use it in
portable code.  __STRING() and __P(() are less portable than #name
or prototypes.

For portability, you should define your own macros, e.g., for
ANSI:

#define P__(x)		x
#define STR(x)		STR1(x)
#define STR1(x)		#x

STR(x) should normally be used instead of #x even if there are
no portablility considerations, since STR1(x) usually does the
wrong thing if x is a macro (x doesn't get expanded).

The nested macro trick for STR(x) doesn't work in traditional
mode and isn't used in <sys/cdefs.h>.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199510271304.XAA13158>