[top-level] C++-friendly allocators for libiberty

Bernardo Innocenti bernie@develer.com
Sat Jun 26 04:18:00 GMT 2004


Alexandre Oliva wrote:
> On Jun 25, 2004, Bernardo Innocenti <bernie@develer.com> wrote:
> 
> 
>>+#define xcnewvec(T, N)		(T *) xcalloc (N, sizeof (T))
>>+#define xresize(T, P, S)	(T *) xrealloc (P, S)
>>+#define xresizevec(T, P, N)	(T *) xrealloc (P, sizeof (T) * (N))
>>+#define xobnew(O, T)		(T *) obstack_alloc (O, sizeof (T))
> 
> 
> You're missing parentheses around N, P (twice), S and O.

I had used them the first time, but then removed them because
I thought there would be no way to pass an argument containing
a comma through the C89 preprocessor.

Actually, there's:

  #define foo ,
  xresize(struct foo, f, 10);

...but how could one possibly abuse this to generate code
that actually compiles?

-- 
  // Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/  http://www.develer.com/



More information about the Binutils mailing list