[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

An ANSI C preprocessor user question



Greetings, joly people.

I was wondering if a code like this:

<-- code start ---------------------------------------------------->
#define	cat(a,b)	a##b

int main (void)
{
	cat(#define,)	I_am_defined
#	ifdef	I_am_defined
		/* I'm defined! I know what I am! Youpieeee! */
		return (0);
#	else /* I_am_defined */
		/* Oh, hell. What am I? Am I I, or not???? */
		return (1);
#	endif /* I_am_defined */
}
<-- code end ------------------------------------------------------>

be pre-processed like this:

<-- pre-processed code start -------------------------------------->
# 1 "p2.c"


int main (void)
{
	#define     I_am_defined





		return (1);

}
<-- pre-processed code end ---------------------------------------->

or rather, like this:

<-- pre-processed code start -------------------------------------->
# 1 "p2.c"


int main (void)
{
 


		return (0);


 

}
<-- pre-processed code end ---------------------------------------->

? My cpp (

<-- cpp -v output start ------------------------------------------->
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.2/specs
gcc version 2.95.2 20000220 (Debian GNU/Linux)
 /usr/lib/gcc-lib/i386-linux/2.95.2/cpp -lang-c -v -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix) -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -
GNU CPP version 2.95.2 20000220 (Debian GNU/Linux) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc-lib/i386-linux/2.95.2/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
 /usr/lib/gcc-lib/i386-linux/2.95.2/../../../../include/g++-3
 /usr/lib/gcc-lib/i386-linux/2.95.2/../../../../i386-linux/include
End of omitted list.
<-- cpp -v output end --------------------------------------------->

) produces the first version, and I need the second one for my business.

I have been trying to find the answer from an ANSI C specification on the net,
but failed to find any such document. A pointer would be appreciated as well.

Thanks, for your efforts to read my bulky message.
Merry Christmas friends,
-- 
Pavel M. Penev



Reply to: