This is the mail archive of the gcc-help@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]

Problem using: gcc -DREL="test" x.c


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.)


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