This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: What the heck is name2?



> >     I'm trying to rebuild a large piece of code from work that is looking
> > for a "generic.h".  Specifically, it's looking for something called the
> > name2 macro.
> >     Now, the lead programmer on the project insists that generic.h is
> > provided by the compiler distribution so since I'm "foolishly" using egcs
> > 1.1.1, it's my fault.

generic.h was a cfront-ism.  It's basically support for using the
preprocessor to do fake templates by token-pasting.  It is seriously
obsolete stuff, since most uses are obsoleted by the introduction of
templates.  Your lead programmer must be an old-timer.

name2(x,y) just returns a token formed by pasting x and y together.
Here's the definition from the old libg++:

#define name2(a,b) gEnErIc2(a,b)
#define gEnErIc2(a,b) a ## b

(the reason you need an extra level of indirection is because of
the order that the preprocessor does substitutions, though at least
in some cases it seems that one level works).

HJ writes:

> name2/generic.h is in the libg++ addon.

HJ's always trying to get us to bring libg++ back. :-) It's deprecated
because it's full of stuff people shouldn't be using anymore, like
genclass to instantiate fake templates and the like.  The only useful
stuff in libg++ are the random number classes: they can generate lots
of different probability distributions for you.  (The container classes
are done better by STL).

However, the generic.h in libg++ doesn't depend on anything else, so
you could just grab it and use only that file.

The file says it is under the LGPL, but I don't know what meaning this
has considering that the file has nothing but short macros in it.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]