This is the mail archive of the
mailing list for the GCC project.
Re: Problem with macro params containing commas
On Fri, Aug 15, 2003 at 05:24:18PM +0200, Andreas Schwab wrote:
> skaller <email@example.com> writes:
> |> On Fri, 2003-08-15 at 02:11, Jean-Eric Cuendet wrote:
> |> > Hi,
> |> > I'd like to pass params that contains commas to a macro.
> |> > But the macro processor think that the passed param is 2 parts (separated by the
> |> > inner macro). It's normal, but not what I want...
> |> > Is there a way to do it differently?
> |> > Thanks
> |> > -jec
> |> I use:
> |> #define comma ,
> |> ... offsetof(X<A comma B>,x) ...
> In this case you can just put parens around X<A,B>: offsetof((X<A,B>),x).
And if you're dealing with really ugly macro patterns, see
libstdc++-v3/include/bits/concept_check.h for another way to handle this.
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it.
- Brian W. Kernighan