This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
#elseif and #ifdef funnies
- To: Mailing List - GCC <gcc at gcc dot gnu dot org>
- Subject: #elseif and #ifdef funnies
- From: Alex Buell <alex dot buell at tahallah dot demon dot co dot uk>
- Date: Thu, 1 Nov 2001 00:59:42 +0000 (GMT)
- Reply-To: <alex dot buell at tahallah dot demon dot co dot uk>
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