[net.lang.c] C preprocessor: bug or intentional deficiency?

johnsson@chalmers.UUCP (Thomas Johnsson) (04/03/85)

How do I get a C macro to define another macro? Or rather,
the expansion of a macro causes another macro to be defined.
For example,

	#define defineit(d) \
	#define d hello

The call to defineit

	defineit(hi)

would cause the definition

	#define hi hello

to be entered into the C preprocessor translation table.
Except that it does not seem to work (no matter what permutation
of backslashes and hashes I try :-)

It's clearly a very useful thing to be able to do!
Don't be misled by the triviality of my example above;
Consider the following example, which is more in the spirit of
what I'm trying to do:

	#define defnode2(name) \
	#define make_/**/name(a,b) \
		....		   \
	#define is_/**/name(p) \
		....

Thus I want 

	defnode2(banana)

to mean exactly the same as

	#define make_banana(a,b) \
		....		   \
	#define is_banana(p) \
		....

That this does not work, is it a bug in the preprocessor,
or is it just not supposed to work? If so, why not?

-- 
____________________________________________________________
Thomas Johnsson		..decvax!mcvax!enea!chalmers!johnsson
Chalmers University of Technology, Goteborg, Sweden

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (04/06/85)

> How do I get a C macro to define another macro? Or rather,
> the expansion of a macro causes another macro to be defined.
> ...
> That this does not work, is it a bug in the preprocessor,
> or is it just not supposed to work? If so, why not?

The C preprocessor is NOT a general macro processor,
nor is it intended to be.  If you have m4, use that;
otherwise punt.