This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Problem using: gcc -DREL="test" x.c
- To: <gcc-help at gcc dot gnu dot org>
- Subject: Problem using: gcc -DREL="test" x.c
- From: "Shikhar Sarkar" <shikhar at utstar dot com>
- Date: Thu, 4 Oct 2001 14:07:50 -0700
- Cc: "Manoj Saxena" <msaxena at utstar dot com>
Hi,
I will highly appreciate if someone can tell me how to pass a string
constant in compiler option -D. Say, if I give -Dmacro=5, it works, but if I
give -Dmacro="test", it fails in the compilation process. How can I specify
string as a command line option.
Shikhar Sarkar
Senior Research Engineer
UTStarcom Inc.
New Jersey
Following are the details:
Works correctly: gcc -DNUM=5 x.c [assignment to an integer works]
Does not work: gcc -DREL="test" [assignment to string does not work]
Test program:
main ()
{
char rel[100] = REL;
puts(rel);
printf("%d", NUM);
}
Compilation:
$ g++ -DNUM=5 -DREL="test" rel.c
rel.c: In function `int main()':
rel.c:5: `test' undeclared (first use this function)
rel.c:5: (Each undeclared identifier is reported only once
rel.c:5: for each function it appears in.)