This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/57345] New: Preprocessor fails to evaluation string token not valid
- From: "signupnathan at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 20 May 2013 22:10:44 +0000
- Subject: [Bug c/57345] New: Preprocessor fails to evaluation string token not valid
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57345
Bug ID: 57345
Summary: Preprocessor fails to evaluation string token not
valid
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: signupnathan at gmail dot com
This error
23L03.c: In function âmainâ:
23L03.c:16:10: error: token ""I know the C language.\n"" is not valid in
preprocessor expressions
23L03.c:20:10: error: token ""I know BASIC.\n"" is not valid in preprocessor
expressions
Is generated by the following code that compliles fine with clang. Code comes
from a book teaching about C in a preprocessor chapter.
#include <stdio.h>
#define C_LANG 'C'
#define B_LANG 'B'
#define NO_ERROR 0
int main(void)
{
#if C_LANG == 'C' && B_LANG == 'B'
#undef C_LANG
#define C_LANG "I know the C language.\n"
#undef B_LANG
#define B_LANG "I know BASIC.\n"
printf("%s%s", C_LANG, B_LANG);
#elif C_LANG == 'C'
#undef C_LANG
#define C_LANG "I only know C language.\n"
printf("%s", C_LANG);
#elif B_LANG == 'B'
#undef B_LANG
#define B_LANG "I only know BASIC.\n"
printf("%s", B_LANG);
#else
printf("I don't know C or BASIC.\n");
#endif
return NO_ERROR;
}
The preprocessor balks at this type of statement:
#if "foo" == "foo"
printf("foo matches");
#endif