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]

#elseif and #ifdef funnies


I just stumbled across something strange with the #elseif and #elif
pragmas tonight. Here's a program snippet:

#include <stdio.h>

/* #define one */
#define two 1

int main(int argc, char *argv[])
{

#if defined(one)
	printf("One found\n");
#elif defined(two)
	printf("Two found\n");
#else
	printf("One and two not found\n");
#endif

	return 0;
}

This works, produces the expected output 'Two found'. However, if I do a
s/elif/elseif, and compile it, the output is wrong, it prints 'One and two
found'.

I was under the impression that #elseif and #elif were functionally the
same. Is this not true?

Gcc is 2.95.3, on sparc32-linux, with binutils 2.10.1.

-- 
Come the revolution, humourless gits'll be first up against the wall.

http://www.tahallah.demon.co.uk


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