This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Using define inside a #define
- From: Ian Lance Taylor <iant at google dot com>
- To: Oliver King-Smith <wine at tescina dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Thu, 28 Jul 2011 12:31:11 -0700
- Subject: Re: Using define inside a #define
- References: <BB437D22-454B-4E16-AE99-C3BFEDEE029C@tescina.com>
Oliver King-Smith <wine@tescina.com> writes:
> I would like to define a macro like
>
> #define MAKE_REG( r, a) #define r (*(unsigned int *)(a))
>
> Obviously I can put a define on the same line but what I want is to be able to write:
> MAKE_REG( CRTL2, 0x1000020 );
>
> And then use CRTL2 just like I did CTRL1. Is there any way of achieving my result in ANSI C?
No.
I would write a generator program. Or if using C++ have the macro
define inline functions which return a reference.
Ian